SEPURI-SAI-KRISHNA opened a new issue, #13469:
URL: https://github.com/apache/seatunnel/issues/13469

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues. Related but different: #13044, #13060, #13298.
   
   ### What happened
   
   On Zeta, a sink that has a `SinkCommitter` but no `SinkAggregatedCommitter` 
can lose every row of one checkpoint. Kafka `EXACTLY_ONCE`, Doris with 2PC, 
Pulsar `EXACTLY_ONCE` and BigQuery are such sinks.
   
   `SinkFlowLifeCycle` keeps the commit info of the last checkpoint only in 
memory (`lastCommitInfo`) and commits it in `notifyCheckpointComplete`. The 
commit info is not part of the checkpoint (only the writer state is), and 
nothing commits it after a restore. So when that commit fails (run below), or 
the worker stops after the checkpoint completed but before the commit (read), 
the pipeline restores from that checkpoint, the source continues after it, and 
the transaction of that checkpoint is never committed.
   
   Reproduced on an in-process Zeta node with the engine code of dev 
`60e039a810`: streaming FakeSource (50 rows, 5 splits) to a test sink that has 
writer state and only a plain committer.
   
   | Run | Rows written | Rows committed | Rows of checkpoint 1 committed |
   |---|---|---|---|
   | no failure | 50 | 50 | 10 of 10 |
   | commit of checkpoint 1 throws once | 50 | 40 | 0 of 10 |
   
   In the second run the pipeline went to CANCELING and FAILED, restored once 
from checkpoint 1 (the writer got its checkpoint 1 state) and committed 
checkpoints 2 to 4. The 10 rows of checkpoint 1 were neither committed nor 
aborted, and the job stayed RUNNING. The source did not send them again: both 
runs wrote 50 distinct rows.
   
   The numbers are the same when the sink is wrapped in `MultiTableSink`, as 
Doris, Pulsar and BigQuery are on Zeta (Kafka is not wrapped, like the test 
sink above).
   
   For Kafka (read, not run): on restore `KafkaSinkWriter` aborts the 
transactions from the restored checkpoint + 1 on and begins a new one, so the 
transaction of the restored checkpoint stays open until the broker's 
transaction timeout aborts it. `KafkaCommitInfo` already holds the producer id 
and epoch that would let it be resumed and committed. Flink 1.15 is not 
affected (read): its committer operator keeps the committables in its 
checkpointed state.
   
   The same code is in 2.3.13, 3.0.0 and 3.1.0.
   
   ### SeaTunnel Version
   
   dev (60e039a810), and 3.1.0
   
   ### SeaTunnel Config
   
   ```conf
   env {
     parallelism = 1
     job.mode = "STREAMING"
     checkpoint.interval = 3000
   }
   source {
     FakeSource {
       row.num = 50
       split.num = 5
       split.read-interval = 2000
       schema = { fields { name = "string", age = "int" } }
     }
   }
   sink {
     # test sink: writer state and a plain SinkCommitter only; its first 
non-empty commit throws once
     PlainCommitProbe {}
   }
   ```
   
   ### Running Command
   
   ```shell
   In-process Zeta node (AbstractSeaTunnelServerTest), job submitted with 
startJob. Happy to share the probe.
   ```
   
   ### Error Exception
   
   ```log
   ERROR [CheckpointFinishedOperation] ... SeaTunnelEngineException: 
java.io.IOException: injected commit failure for checkpoint 1
   INFO  [SubPlan] ... Pipeline: [(1/1)] turned from state RUNNING to CANCELING.
   INFO  [SubPlan] ... Pipeline: [(1/1)] turned from state CANCELING to FAILED.
   INFO  [SubPlan] - Restore time 1, pipeline ... Pipeline: [(1/1)]
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta. Flink 1.15 is not affected (see above).
   
   ### Java or Scala Version
   
   JDK 17
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to