ricky2129 opened a new issue, #12805:
URL: https://github.com/apache/seatunnel/issues/12805

   ### 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.
   
   ### What happened
   
   Restoring a Zeta job whose JDBC sink runs with `is_exactly_once = true` 
fails whenever the restored checkpoint's XA transactions were already 
committed, which is the normal case after a failure.
   
   On restore, `SinkAggregatedCommitterTask.restoreState` calls `restoreCommit` 
on the sink's aggregated committer. Every sink runs inside `MultiTableSink`, so 
that is `MultiTableSinkAggregatedCommitter`. It does not override 
`restoreCommit`, so the interface default calls `commit()`, which calls each 
table's `commit()`, never its `restoreCommit()`.
   
   `JdbcSinkAggregatedCommitter.restoreCommit` (#11569) skips transactions that 
are no longer prepared. Because it is never reached, the restore commits the 
checkpoint's XIDs again, MySQL answers `XAER_NOTA`, the commit failure 
propagates, and the job fails to restore.
   
   Reproduced end to end on a 2.3.12-based build with #11569 and #10459 
backported; `MultiTableSinkAggregatedCommitter` on dev is unchanged, so dev 
takes the same path (MySQL-CDC → JDBC, MySQL 8.4):
   1. Run a streaming job with the config below and let a few checkpoints 
complete.
   2. Fail the job, for example a `BEFORE UPDATE` trigger on the target that 
raises an error.
   3. Remove the cause and restore: `seatunnel.sh -r <jobId> -c job.conf`.
   4. The restore fails every time.
   
   ### SeaTunnel Version
   
   dev (c37823b9a); reproduced on 2.3.12 + #11569/#10459
   
   ### SeaTunnel Config
   
   ```conf
   env { parallelism = 1, job.mode = "STREAMING", checkpoint.interval = 5000 }
   source {
     MySQL-CDC {
       base-url = "jdbc:mysql://mysql:3306/s"
       username = "root", password = "pw"
       database-names = ["s"]
       table-pattern = "s\\.t[123]"
       startup.mode = "latest"
     }
   }
   sink {
     Jdbc {
       url = "jdbc:mysql://mysql:3306/m3"
       driver = "com.mysql.cj.jdbc.Driver"
       username = "st", password = "stpw"
       database = "m3"
       table = "${table_name}"
       generate_sink_sql = true
       is_exactly_once = true
       xa_data_source_class_name = "com.mysql.cj.jdbc.MysqlXADataSource"
     }
   }
   ```
   
   ### Running Command
   
   ```shell
   ./bin/seatunnel.sh -c job.conf --async
   ./bin/seatunnel.sh -r <jobId> -c job.conf --async
   ```
   
   ### Error Exception
   
   ```log
   JdbcConnectorException: ErrorCode:[JDBC-03], ErrorDescription:[Xa operation 
failed, such as (commit, rollback) etc..] - unable to commit XA transaction, 
xid: 201:..., error -4: Xid is not valid. [XAER_NOTA: Unknown XID]
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta
   
   ### Java or Scala Version
   
   1.8
   
   ### 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