nzw921rx opened a new pull request, #13054:
URL: https://github.com/apache/seatunnel/pull/13054

   
   ### Purpose of this pull request
   
   Fixes #12624.
   
   This contribution to Apache SeaTunnel prevents JDBC Sink from successfully 
completing a checkpoint after previously flushed but uncommitted batches have 
been lost.
   
   Based on #12625 by @xinnyuli, with the original commits and authorship 
preserved. This branch incorporates the latest `dev`, resolves the 
documentation conflicts, and adds further exception-handling coverage.
   
   With checkpointing enabled and a manual-commit connection, several flushed 
batches can share one transaction. If that transaction is lost through 
connection replacement, reconnect retries, or another table's rollback, 
committing a replacement or incomplete transaction can allow the checkpoint to 
succeed with records missing.
   
   The changes:
   
   - Track flushed but uncommitted work, sharing transaction state between 
table writers on the same connection queue.
   - Refuse commits after connection replacement or rollback has discarded 
unreported work.
   - Prevent retries that would resend only the current batch while earlier 
batches may have been lost.
   - Track rollback and savepoint boundaries across writers sharing a 
transaction.
   - Record transaction loss before data-error handling exits. A mixed 
exception chain containing both a data error and a connection/transaction 
failure must not leave other writers able to commit.
   - Correct the mitigation guidance: reducing `batch_size` does not isolate 
shared transactions, and Oracle cannot use `auto_commit = true` to avoid this 
window.
   
   ### Does this PR introduce *any* user-facing change?
   
   Yes.
   
   For non-XA JDBC Sink jobs with checkpointing enabled and manual-commit 
connections (`auto_commit = false`, including Oracle's enforced manual-commit 
behavior):
   
   - Previously, flushed records could be rolled back while a subsequent 
checkpoint still succeeded.
   - After this change, detected loss of uncommitted work causes the commit to 
fail, allowing recovery from the last successful checkpoint.
   
   Affected jobs may fail and recover instead of retrying a batch locally. In 
multi-table row-error handling, a rollback that discards another table's work 
also prevents further commits on that shared transaction.
   
   Auto-commit connections, jobs without checkpointing, and the XA writer 
retain their existing behavior. Configuration options and checkpoint 
serialization are unchanged.
   
   English and Chinese connector, error-handling, and compatibility 
documentation are updated.
   
   ### How was this patch tested?
   
   - JDBC non-container suite: **1174 tests, 0 failures, 0 errors, 6 skipped**.
   - Added four mocked exception-chain regression cases covering row-error mode 
enabled/disabled with SQLState `40001` and `08006`. All four fail against the 
original implementation and pass after the additional hardening.
   - Coverage includes real HikariCP/SQLite connection replacement, shared 
transactions, rollback/savepoint handling, and healthy commits.
   - Spotless passed.
   - Reactor verification passed for all nine modules with `-pl 
seatunnel-connectors-v2/connector-jdbc -am -DskipTests -DskipIT=true verify`.
   
   Local validation limitations: four Oracle/Kingbase container test classes 
could not initialize without Docker and were excluded from the successful 
non-container run. The included MySQL multi-table checkpoint E2E test was not 
run locally.
   
   ### Check list
   
   - [x] No new dependencies or JAR binaries.
   - [x] English and Chinese documentation updated.
   - [x] Behavior changes and migration guidance documented.
   


-- 
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