Skip to content

[Fix][API] Forward restoreCommit to each table in MultiTableSinkAggregatedCommitter - #12807

Merged
nzw921rx merged 8 commits into
apache:devfrom
ricky2129:fix/multi-table-restore-commit
Oct 28, 2026
Merged

nzw921rx merged 8 commits into
apache:devfrom
ricky2129:fix/multi-table-restore-commit

Conversation

@ricky2129

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

Fixes #12805

Under Zeta every sink runs inside MultiTableSink, so on restore SinkAggregatedCommitterTask calls MultiTableSinkAggregatedCommitter.restoreCommit. It did not override it, and the interface default calls commit(), which calls each table's commit(). So a sink's own restoreCommit was never reached.

For the JDBC XA sink, JdbcSinkAggregatedCommitter.restoreCommit (#11569) skips transactions that are no longer prepared. Without it, a restore re-commits the checkpoint's XIDs, which were usually already committed before the failure: MySQL answers XAER_NOTA, the commit failure propagates, and the job cannot restore.

This PR overrides restoreCommit in MultiTableSinkAggregatedCommitter and routes it to each table's restoreCommit, using the same per-table split as commit().

Does this PR introduce any user-facing change?

Yes. Restoring a job whose sink has its own restoreCommit now uses it. For the JDBC sink with is_exactly_once = true, restores no longer fail with XAER_NOTA. Sinks that don't override restoreCommit are unaffected: the default still calls commit().

How was this patch tested?

Check list

@github-actions github-actions Bot added the api label Oct 15, 2026

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, and for the clear root-cause write-up and the end-to-end validation on the XA path. I went through the full diff and traced the restore call chain; the fix is correct and minimal. I did not find any blocking issues. Details below.

What Problem Does This PR Solve?

  • User pain point: Under Zeta every sink is wrapped in MultiTableSink, so on restore the engine calls MultiTableSinkAggregatedCommitter.restoreCommit. That class did not override it, so the interface default (SinkAggregatedCommitter.restoreCommit -> commit) ran, and a per-table committer's own restoreCommit was never reached. For the JDBC XA sink (JdbcSinkAggregatedCommitter.restoreCommit), this means already-committed XIDs get re-committed on restore, MySQL answers XAER_NOTA, and the job cannot restore.
  • Fix approach: Override restoreCommit in MultiTableSinkAggregatedCommitter and route it to each table committer's restoreCommit, reusing the existing per-table split/merge logic of commit() via a shared private helper.
  • One-sentence summary: Make the multi-table wrapper forward restore to the real per-table restoreCommit instead of silently downgrading it to commit.

1. Code Change Review

1.1 Core Logic Analysis

Changed files / methods

  • seatunnel-api/.../multitablesink/MultiTableSinkAggregatedCommitter.java: commit() now delegates to commitPerTable(info, false); new restoreCommit() delegates to commitPerTable(info, true); the loop body is unchanged except the single call site restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo) (lines ~72-110).
  • seatunnel-api/.../MultiTableSinkAggregatedCommitterTest.java: new testRestoreCommitRoutesToTableRestoreCommit.

Before / after (key lines)

// before: no restoreCommit override -> interface default -> commit()
List errCommitList = sinkCommitter.commit(commitInfo);

// after
List errCommitList =
        restore
                ? sinkCommitter.restoreCommit(commitInfo)
                : sinkCommitter.commit(commitInfo);

Complete runtime path

Job restore from checkpoint (-r)
  -> SinkAggregatedCommitterTask.restoreState(actionStateList)
       [seatunnel-engine-server/.../SinkAggregatedCommitterTask.java:259-278]
      -> deserialize MultiTableAggregatedCommitInfo from checkpoint state
      -> aggregatedCommitter.restoreCommit(infos)            // aggregatedCommitter == MultiTableSinkAggregatedCommitter under Zeta
          BEFORE: not overridden -> SinkAggregatedCommitter.restoreCommit default [SinkAggregatedCommitter.java:42-45]
                  -> MultiTableSinkAggregatedCommitter.commit -> table.commit()   (XA: re-commit committed XIDs -> XAER_NOTA)
          AFTER:  MultiTableSinkAggregatedCommitter.restoreCommit -> commitPerTable(infos, true)
                  -> for each sinkIdentifier: pick that table's info from each MultiTableAggregatedCommitInfo
                  -> table.restoreCommit(perTableInfo)
                      -> JdbcSinkAggregatedCommitter.restoreCommit [JdbcSinkAggregatedCommitter.java:97-105]
                         (reconciles checkpoint XIDs against the RM recovery scan, skips already-resolved ones)
      -> non-empty returned list -> CheckpointException(AGGREGATE_COMMIT_ERROR) [SinkAggregatedCommitterTask.java:275-279]

Key findings

  1. The normal restore path does hit this code: SinkAggregatedCommitterTask.restoreState calls restoreCommit on the committer, and under Zeta that committer is the multi-table wrapper. So this is a main-path fix for restore, not only an edge case.
  2. The change is a precise fix. The per-table split, the error-list merge and the return contract are shared by both entry points through commitPerTable, so commit() behavior is unchanged (restore=false selects the same call as before).
  3. For sinks that do not override restoreCommit, sinkCommitter.restoreCommit(...) resolves to the interface default and calls commit(...), so the effective behavior is identical to today.
  4. I confirmed the only other connector committer overriding restoreCommit is Iceberg (IcebergAggregatedCommitter.java:64-79). Under Zeta it was previously also bypassed by the wrapper; after this PR its own restore logic (isAlreadyCommitted check, then commitFiles) will start to run on restore. That is the intended contract of restoreCommit and looks correct to me, just worth being aware of as a user-visible side effect beyond JDBC.

1.2 Compatibility Impact

Fully compatible.

  • APIs / SPI: no signature change; restoreCommit already exists on SinkAggregatedCommitter, this only overrides it in the wrapper.
  • Config options and defaults: unchanged.
  • Serialization / checkpoint format: unchanged (MultiTableAggregatedCommitInfo is read and written exactly as before).
  • Historical behavior: unchanged for sinks without a custom restoreCommit. For JDBC XA and Iceberg, behavior changes from "restore bypassed to commit" to the documented restoreCommit semantics, which is the bug being fixed. No incompatible-changes.md entry is needed.

1.3 Performance / Side-Effect Analysis

  • CPU / memory / GC: one extra boolean parameter and a ternary; no new allocations or per-record work. The path runs only once per restore.
  • Networking / locks / concurrency: no new threads, locks or shared state. restoreState is already invoked once per committer task.
  • Retries / idempotency: this change improves idempotency on restore for XA/Iceberg, since their restoreCommit already encodes the "skip already resolved" logic.
  • Resource release: unchanged.

1.4 Error Handling and Logging

  • A non-empty list returned from the per-table restoreCommit is merged into errorList exactly as for commit(), and SinkAggregatedCommitterTask.restoreState still converts a non-empty result into CheckpointException(AGGREGATE_COMMIT_ERROR). No exceptions are swallowed and no logging changes.
  • Exceptions thrown by a table's restoreCommit (for example the JDBC JdbcConnectorException) propagate unchanged, as they do for commit().

No blocking issues found.

2. Code Quality Assessment

2.1 Coding Standards

The change follows the existing style, keeps the diff small, and adds an explanatory comment for the new override that states why the override is needed. commitPerTable is a private helper with a self-explanatory name; I do not consider additional Javadoc mandatory there.

2.2 Test Coverage and Test Stability

  • testRestoreCommitRoutesToTableRestoreCommit builds a table committer that records which entry point is called, then calls restoreCommit and commit on the wrapper. It would fail if the override were removed (the call would be recorded as commit[xid-1]), and it also guards against commit() accidentally being routed to restoreCommit. That covers the root-cause behavior directly.
  • Stability rating: Stable. The test is single-threaded and in-memory, has no sleeps, ports, or external resources, and asserts an ordered list that is deterministic (MultiTableSinkAggregatedCommitterTest.java:74-116).
  • Optional, non-blocking: the test uses a single table, so it does not exercise the per-table split with two table identifiers, nor the merged error list returned from restoreCommit. A second table in the same test (and one returning a non-empty list from restoreCommit) would pin the "same per-table split as commit()" claim in the PR description. Not required for merge.

2.3 Documentation Updates

No user-visible option or configuration changed, so docs/en and docs/zh do not need updates.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix. The defect is exactly that the wrapper did not forward a lifecycle method that the interface lets sinks specialize; forwarding it at the wrapper is the right layer (the engine task stays connector-agnostic).

3.2 Maintainability

Clear. Sharing one loop between commit and restoreCommit avoids copy-paste drift. A boolean flag parameter is slightly less readable than two thin lambdas or an enum, but for a private two-caller helper it is fine.

3.3 Extensibility

Any future connector that overrides restoreCommit will now work under Zeta without wrapper changes. As a side thought for a follow-up (not for this PR): other SinkAggregatedCommitter default-method forwards in wrappers could be audited the same way.

3.4 Historical-Version Compatibility

Compatible with existing checkpoints and with previously saved jobs; no state format or option change, no upgrade action needed.

4. Issue Summary

Number Issue Location Severity
- No blocking issues found - -

Optional suggestion (non-blocking, not numbered): extend the new test with a second table and a non-empty error-list return from restoreCommit.

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers - must be fixed

    • None on the source side.
  2. Recommended fixes - non-blocking

    • Optionally broaden the unit test to two tables and the error-list path, as described above. It does not block merge because the existing test already fails without the override and the shared loop is unchanged.

CI / merge gate: at the time of this review the Build check for head f3e7a8b was still queued (the real signal runs in the contributor's fork; the run is https://github.com/ricky2129/seatunnel/actions/runs/38750864232). The branch is also 1 commit behind dev, which is only a metadata observation and not a request to rebase. Please make sure the fork run completes green; once it does I do not see anything else standing in the way.

Overall assessment: A small, correct, well-tested fix for a real restore failure on the JDBC XA path under Zeta. I do not see a better alternative location for the fix. Thanks again for tracking this down!

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, and for keeping the branch in sync with dev. I re-reviewed the new head f3891ac. Nothing in the PR's own change moved since my previous round on f3e7a8b: the last two commits are merges of dev only, and the PR's net diff against dev is still just the two files below. My earlier conclusion stands, and I have no new findings.

What Problem Does This PR Solve?

  • User pain point: Under Zeta every sink runs inside MultiTableSink, so on restore the engine calls MultiTableSinkAggregatedCommitter.restoreCommit. The wrapper did not override it, so the interface default (commit) ran and a table committer's own restoreCommit was never reached. For the JDBC XA sink this re-commits already-committed XIDs, MySQL answers XAER_NOTA, and the job cannot restore.
  • Fix approach: Override restoreCommit in the wrapper and route it to each table committer's restoreCommit, sharing the per-table split/merge loop with commit() through a private helper.
  • One-sentence summary: The multi-table wrapper now forwards restore to the real per-table restoreCommit instead of silently downgrading it to commit.

1. Code Change Review

1.1 Core Logic Analysis

Net PR diff against current dev (re-verified on this head):

  • seatunnel-api/.../multitablesink/MultiTableSinkAggregatedCommitter.java: commit() delegates to commitPerTable(info, false); new restoreCommit() delegates to commitPerTable(info, true); the only behavioral line is restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo).
  • seatunnel-api/.../MultiTableSinkAggregatedCommitterTest.java: new testRestoreCommitRoutesToTableRestoreCommit.

Runtime path: SinkAggregatedCommitterTask.restoreState -> aggregatedCommitter.restoreCommit(infos) (the multi-table wrapper under Zeta) -> commitPerTable(infos, true) -> each table's restoreCommit (for example JdbcSinkAggregatedCommitter.restoreCommit). This is the normal restore path, not an edge case. For sinks that do not override restoreCommit, the interface default still calls commit, so their behavior is unchanged. A side effect worth knowing about: Iceberg's restoreCommit was also bypassed before and will now run on restore, which is the intended contract.

The extra files that appear when comparing the two heads directly (AGENTS.md, CLAUDE.md symlink removal, the multi_table_sink_replica check in MultiTableSink) come from dev (#12568, #12811) and are not part of this PR.

1.2 Compatibility Impact

Fully compatible. No API/SPI signature, option, default or checkpoint serialization change. MultiTableAggregatedCommitInfo is read and written as before. No incompatible-changes.md entry needed.

1.3 Performance / Side-Effect Analysis

One boolean and a ternary on a path that runs once per restore. No new threads, locks, allocations in hot paths or resources. Idempotency on restore improves for XA and Iceberg.

1.4 Error Handling and Logging

Non-empty per-table results are merged into the error list exactly as for commit(), and restoreState still converts a non-empty result into CheckpointException. Exceptions propagate unchanged; nothing is swallowed.

No blocking issues found.

2. Code Quality Assessment

2.1 Coding Standards

Small, consistent with the file's style, and the new override carries a comment explaining why it exists.

2.2 Test Coverage and Test Stability

testRestoreCommitRoutesToTableRestoreCommit records which entry point each table committer receives and asserts restoreCommit[xid-1] then commit[xid-1]. It turns red if the override is removed or if commit() is mis-routed. Stability rating: Stable (single-threaded, in-memory, no sleeps, ports or external resources; deterministic ordered assertion at MultiTableSinkAggregatedCommitterTest.java around lines 74-116).

Optional, non-blocking: add a second table and a non-empty error list returned from restoreCommit to pin the "same per-table split as commit()" claim.

2.3 Documentation Updates

No user-visible option changed, so docs/en and docs/zh need no update.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix, at the right layer: the wrapper forwards a lifecycle method that sinks may specialize, and the engine task stays connector-agnostic.

3.2 Maintainability

Clear; one shared loop avoids copy-paste drift. The boolean flag is slightly less readable than two lambdas, but fine for a private two-caller helper.

3.3 Extensibility

Future connectors that override restoreCommit will work under Zeta without further wrapper changes.

3.4 Historical-Version Compatibility

Compatible with existing checkpoints and saved jobs; no upgrade action needed.

4. Issue Summary

Number Issue Location Severity
- No blocking issues found - -

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers - must be fixed

    • None.
  2. Recommended fixes - non-blocking

    • Optionally broaden the unit test to two tables and the error-list path. It does not block merge because the existing test already fails without the override.

CI / merge gate: at the time of this review the Build check on head f3891ac is still in progress (the real signal runs in the contributor's fork), so I am not approving yet. The branch is ahead of dev with no conflicts (behind_by=0). Once the fork run finishes green, I do not see anything else standing in the way.

Overall assessment: A small, correct, well-tested fix for a real restore failure on the JDBC XA path under Zeta. Thanks again!

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I reviewed the latest head 73f6621c27ce.

What this PR fixes

  • User pain: On Zeta restore, SinkAggregatedCommitterTask.restoreState calls MultiTableSinkAggregatedCommitter.restoreCommit, which fell through to the SinkAggregatedCommitter default (return commit(aggregatedCommitInfo)), so a connector's own restoreCommit -- notably the prepared-XID reconciliation in JdbcSinkAggregatedCommitter.restoreCommit -- was unreachable and XA restores re-committed already-committed XIDs and failed with XAER_NOTA.
  • Fix approach: MultiTableSinkAggregatedCommitter now overrides restoreCommit (MultiTableSinkAggregatedCommitter.java:81-83, return commitPerTable(aggregatedCommitInfo, true)); commit and restoreCommit share commitPerTable(..., boolean restore), which keeps the existing per-table split and positional error-list merge and dispatches restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo) (:102-105); a unit test asserts the restore call reaches the table committer's restoreCommit, not commit.
  • One-line summary: Small, correct, well-targeted fix for the Zeta restore path with a focused regression test; only Zeta drives restoreCommit (the only production caller is SinkAggregatedCommitterTask.java:275), and the remaining points are non-blocking: the restore branch inherits the fail-fast, no-table-identifier loop and the raw List from commit(), the test covers one table with an empty retry list, the override also activates IcebergAggregatedCommitter.restoreCommit under Zeta for the first time, and the architecture doc still shows a stale restoreCommit signature.

Runtime chain I rechecked

SinkAggregatedCommitterTask.restoreState()  SinkAggregatedCommitterTask.java:260
  -> aggregatedCommitter.restoreCommit(aggregatedCommitInfos)  SinkAggregatedCommitterTask.java:275
     -> MultiTableSinkAggregatedCommitter.restoreCommit()  MultiTableSinkAggregatedCommitter.java:81  [NEW override; previously SinkAggregatedCommitter.restoreCommit default -> commit()  SinkAggregatedCommitter.java:42-44]
        -> commitPerTable(aggregatedCommitInfo, true)  MultiTableSinkAggregatedCommitter.java:83
           -> per sinkIdentifier: split MultiTableAggregatedCommitInfo by table  MultiTableSinkAggregatedCommitter.java:93-101
           -> restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo)  MultiTableSinkAggregatedCommitter.java:102-105
              -> JdbcSinkAggregatedCommitter.restoreCommit()  JdbcSinkAggregatedCommitter.java:97
                 -> tryOpen(); replayRecoveredCheckpoint(xidInfoList, recoverCheckpointTransactions())  JdbcSinkAggregatedCommitter.java:99-104
           -> positional merge of per-table retry lists into errorList  MultiTableSinkAggregatedCommitter.java:110-115
  -> if returned list non-empty: throw CheckpointException(AGGREGATE_COMMIT_ERROR)  SinkAggregatedCommitterTask.java:276-278

Findings

Issue 1: restoreCommit fails fast on the first table that throws; remaining tables' in-doubt XA transactions stay prepared and the propagated exception carries no table identifier

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:104
  • Why it matters: - Root cause: commitPerTable has no per-table error handling. When restore is true, sinkCommitter.restoreCommit(commitInfo) at MultiTableSinkAggregatedCommitter.java:104 runs inside the plain for loop over aggCommitters.keySet(); the first exception from any table (for JDBC XA, JdbcSinkAggregatedCommitter.restoreCommit starts with tryOpen(), which throws JdbcConnectorException when the XA facade cannot be opened, and replayRecoveredCheckpoint fails closed on XID gaps) unwinds the whole loop. The sibling abort() and close() methods in this same class deliberately catch per table, log, keep the first throwable and rethrow after the loop.
  • Impact: now that this branch is what SinkAggregatedCommitterTask.restoreState (SinkAggregatedCommitterTask.java:275) reaches, one failing table means every later table's prepared XA branches are never reconciled on that restore attempt, and the exception that surfaces does not say which sinkIdentifier failed, so the operator has to guess which target to inspect.
  • Fix: wrap the per-table dispatch in the same try/catch pattern abort() uses -- log with sinkIdentifier, remember the first throwable, continue the loop, rethrow at the end (wrapping the identifier into the message). Applying it to both branches keeps commit and restoreCommit consistent; at minimum the restore branch should get it.
  • Evidence: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:103 restore; seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:104 ? sinkCommitter.restoreCommit(commitInfo); seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:105 : sinkCommitter.commit(commitInfo);
  • Suggested fix: Now that this branch is the one Zeta's SinkAggregatedCommitterTask.restoreState reaches, an exception from one table's restoreCommit (e.g. JdbcSinkAggregatedCommitter.restoreCommit → tryOpen() or a fail-closed XID gap) aborts the loop and leaves every later table's prepared XA branches unreconciled, and the exception that surfaces does not name the table. abort() and close() in this class already catch per table, log, keep the first throwable and rethrow after the loop. Could we apply the same pattern here (at least for the restore branch), so one bad table does not block recovery of the others and the error names sinkIdentifier?
  • Severity: Medium

Issue 2: Architecture doc still shows a stale restoreCommit signature and says nothing about the multi-table wrapper forwarding it; this PR is what makes the hook reachable under Zeta, so the doc should be corrected alongside it

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:81
  • Why it matters: - Root cause: docs/en/architecture/api-design/sink-architecture.md:528-532 documents SinkAggregatedCommitter.restoreCommit as default void restoreCommit(List<AggregatedCommitInfoT> aggregatedCommitInfos) throws IOException {} with the description "Restore committer state from checkpoint". The real interface (seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SinkAggregatedCommitter.java:42-45) returns List<AggregatedCommitInfoT> (the retry list) and defaults to commit(aggregatedCommitInfo), and the new override at MultiTableSinkAggregatedCommitter.java:81-83 is the piece that makes a connector's restoreCommit reachable at all under Zeta.
  • Impact: a connector author following the doc would write a void method that does not override anything and would not learn that, under Zeta, their restoreCommit receives only their own table's commit infos via the multi-table wrapper.
  • Fix: correct the signature and description in sink-architecture.md:528-532 to match the interface, and add a sentence noting that MultiTableSinkAggregatedCommitter forwards restoreCommit per table.
  • Evidence: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:83 return commitPerTable(aggregatedCommitInfo, true);; seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:81 public List<MultiTableAggregatedCommitInfo> restoreCommit(; seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:82 List<MultiTableAggregatedCommitInfo> aggregatedCommitInfo) throws IOException {
  • Suggested fix: Since this override is what finally makes a connector's restoreCommit reachable under Zeta, could you also fix the architecture doc in the same PR? docs/en/architecture/api-design/sink-architecture.md:531-532 still shows default void restoreCommit(...) throws IOException {}, which is neither the real signature (it returns List<AggregatedCommitInfoT> and defaults to commit(...)) nor the real contract. A short note there that MultiTableSinkAggregatedCommitter forwards restoreCommit per table (so a connector only sees its own table's commit infos) would save the next connector author from implementing a method that never overrides anything.
  • Severity: Medium

Issue 3: User-visible restore behaviour changes for JDBC XA and Iceberg under Zeta, but there is no release/upgrade note; the existing JDBC XA entry in incompatible-changes.md describes behaviour that was not actually reachable before this PR

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:104
  • Why it matters: - Root cause: commitPerTable(..., true) at MultiTableSinkAggregatedCommitter.java:102-105 now dispatches to sinkCommitter.restoreCommit(commitInfo). On disk the only two production overrides are JdbcSinkAggregatedCommitter.restoreCommit (JdbcSinkAggregatedCommitter.java:97) and IcebergAggregatedCommitter.restoreCommit (IcebergAggregatedCommitter.java:64-78, which skips checkpoints where filesCommitter.isAlreadyCommitted(...)). Under Zeta neither was invoked before this PR because the wrapper fell through to commit().
  • Impact: docs/en/introduction/concepts/incompatible-changes.md:187-193 already describes the JDBC XA restore semantics (recovery-order evidence, fail-closed gaps) as if they were in effect, yet under Zeta they only take effect with this PR; Iceberg restores also start skipping already-committed checkpoints. Neither change is recorded anywhere a user upgrading would see it, and the PR description only mentions JDBC.
  • Fix: add a short entry under ## dev in incompatible-changes.md stating that the multi-table wrapper now forwards restoreCommit, so the JDBC XA restore semantics described there apply under Zeta and Iceberg restores skip already-committed checkpoints; mention Iceberg in the PR's user-facing-change section.
  • Suggested fix: This line is what activates both JdbcSinkAggregatedCommitter.restoreCommit and IcebergAggregatedCommitter.restoreCommit under Zeta for the first time (those are the only two production overrides in the tree). docs/en/introduction/concepts/incompatible-changes.md:187-193 already describes the JDBC XA restore semantics as if they were in effect, so a one-line note under ## dev saying the multi-table wrapper now forwards restoreCommit (and that Iceberg restores will skip already-committed checkpoints) would make the upgrade story consistent. Mentioning Iceberg in the PR description's user-facing section would help too.
  • Severity: Low

Issue 4: This override also activates IcebergAggregatedCommitter.restoreCommit under Zeta for the first time; the PR only validated JDBC XA, and the existing Iceberg savepoint IT ran while that code was unreachable

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:83
  • Why it matters: - Root cause: the override at MultiTableSinkAggregatedCommitter.java:80-84 forwards to every table committer's restoreCommit. Across the repo only two connectors override it: JdbcSinkAggregatedCommitter.restoreCommit (XID reconciliation) and IcebergAggregatedCommitter.restoreCommit (IcebergAggregatedCommitter.java:64-78: filesCommitter.isAlreadyCommitted(checkpointId, allResults) then skip or commitFiles).
  • Impact: Zeta wraps sinks in MultiTableSink, so until now Iceberg restores on Zeta went through commit() and re-ran commitFiles for every checkpoint. IcebergSinkParallelCommitIT.testRecoveryFromSavepointProducesNoDuplicateSnapshots (IcebergSinkParallelCommitIT.java:261-265) is disabled on Spark and Flink, so it is Zeta-only and its Javadoc at line 249 says it exercises IcebergAggregatedCommitter.restoreCommit() -- yet that method could not have executed on Zeta before this PR. This change is therefore the first time the IT actually drives the isAlreadyCommitted skip branch, and the PR's end-to-end validation covered only MySQL-CDC → JDBC XA.
  • Fix: run connector-iceberg-e2e on this head and confirm the savepoint recovery test still passes with restoreCommit genuinely executing; add Iceberg to the user-facing-change section of the description.
  • Evidence: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:83 return commitPerTable(aggregatedCommitInfo, true);
  • Suggested fix: Worth noting in the description: besides JDBC XA, this also makes IcebergAggregatedCommitter.restoreCommit (the isAlreadyCommitted skip) reachable on Zeta for the first time. IcebergSinkParallelCommitIT.testRecoveryFromSavepointProducesNoDuplicateSnapshots is Zeta-only and its Javadoc says it exercises that method, but until this change the restore went through commit() instead -- so this PR is the first time it actually tests that branch. Please make sure connector-iceberg-e2e is run on this head and add Iceberg to the user-facing-change section.
  • Severity: Low

Issue 5: The new test exercises a single table whose restoreCommit returns an empty list; the per-table split and the retry-list merge on the restore path are not covered

  • Location: seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:115
  • Why it matters: - Root cause: testRestoreCommitRoutesToTableRestoreCommit registers one committer ("table1") and both stub methods return Collections.emptyList(), so the assertion at MultiTableSinkAggregatedCommitterTest.java:114-115 only proves the dispatch flag at MultiTableSinkAggregatedCommitter.java:102-105 picks the right method.
  • Impact: the refactor moved the filtering (.get(sinkIdentifier) + Objects::nonNull) and the positional errorList merge (MultiTableSinkAggregatedCommitter.java:110-115) into the shared commitPerTable, and SinkAggregatedCommitterTask.restoreState turns a non-empty return into CheckpointException(AGGREGATE_COMMIT_ERROR). Nothing in this class checks that, on the restore path, each table committer only receives its own entries or that a table's returned retry list is re-keyed under the correct sinkIdentifier.
  • Fix: add a second case with two tables where table1.restoreCommit returns its input and table2.restoreCommit returns empty; assert each stub saw only its own entries and that the wrapper returns one MultiTableAggregatedCommitInfo whose map contains only table1.
  • Evidence: seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:115 Arrays.asList("restoreCommit[xid-1]", "commit[xid-1]"), calls);; seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:111 committer.restoreCommit(infos);; seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:114 Assertions.assertIterableEquals(
  • Suggested fix: Nice, this pins the routing bug. Since the PR also moves the per-table filtering and the errorList merge into the shared commitPerTable, it would be worth one more case in this class with two tables where table1.restoreCommit returns its input and table2 returns empty: assert each stub only saw its own entries and that the wrapper's returned list has one MultiTableAggregatedCommitInfo containing only table1. That covers the retry-list path SinkAggregatedCommitterTask.restoreState depends on.
  • Severity: Low

Issue 6: New test covers one table with an all-success return; the multi-table split and the positional retry-list merge on the restore path are not exercised

  • Location: seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:106
  • Why it matters: - The added test registers a single table1 committer whose restoreCommit (MultiTableSinkAggregatedCommitterTest.java:88-91) returns Collections.emptyList(), so the only thing asserted is the dispatch choice at MultiTableSinkAggregatedCommitter.java:104.
  • The behaviour this PR introduces for real jobs is per-table routing of restore across multiple tables and merging each table's returned retry list into errorList by position (MultiTableSinkAggregatedCommitter.java:110-115), which SinkAggregatedCommitterTask.restoreState turns into CheckpointException(AGGREGATE_COMMIT_ERROR) when non-empty. Neither the split nor the merge is exercised on the restore path.
  • Fix: add a two-table case in which one restoreCommit returns a non-empty retry list and assert
  • (a) each table committer received only its own infos and
  • (b) the returned MultiTableAggregatedCommitInfo carries the retry entry under the correct identifier.
  • Evidence: seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:86 return Collections.emptyList();; seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitterTest.java:106 info.put("table1", "xid-1");
  • Suggested fix: This proves the dispatch to restoreCommit, which is the core of the fix. Since commitPerTable is now shared, it would be worth one more case with two tables where one restoreCommit returns a non-empty retry list, asserting (a) each table committer only sees its own infos and (b) the returned MultiTableAggregatedCommitInfo carries the retry entry under the correct identifier — that is the path SinkAggregatedCommitterTask.restoreState turns into AGGREGATE_COMMIT_ERROR.
  • Severity: Low

Issue 7: Explanatory // comment above an @Override and a raw List on the changed line; this package uses Javadoc for method contracts

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:78
  • Why it matters: - MultiTableSinkAggregatedCommitter.java:78-79 explain why the override exists using a // line comment directly above @Override. SinkAggregatedCommitter (SinkAggregatedCommitter.java:41) and JdbcSinkAggregatedCommitter.restoreCommit (JdbcSinkAggregatedCommitter.java:86-95) document method contracts with Javadoc, and this rationale is exactly what the next reader of restoreCommit needs to see in the IDE.
  • MultiTableSinkAggregatedCommitter.java:102 keeps the raw List errCommitList while assigning from sinkCommitter.restoreCommit(commitInfo) / sinkCommitter.commit(commitInfo); only size() and get(i) are used afterwards (:106-114), so List<?> compiles against the SinkAggregatedCommitter<?, ?> return type and avoids widening raw-type usage.
  • Fix: convert the two-line comment into a Javadoc block on restoreCommit, and declare List<?> errCommitList.
  • Evidence: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:79 // differently from commit; the inherited default would route it to commit instead.; seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:102 List errCommitList =; seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:78 // Restore must reach each table's restoreCommit, which may treat already-resolved commits
  • Suggested fix: Nit: this rationale is useful — could it be a Javadoc block on restoreCommit instead of a // comment above @Override, matching how SinkAggregatedCommitter and JdbcSinkAggregatedCommitter.restoreCommit document their contracts? Also, on line 102 List<?> errCommitList works against the SinkAggregatedCommitter<?, ?> return type and avoids adding another raw List.
  • Severity: Low

Issue 8: Changed line keeps a raw List for the committer's return value; List<?> is sufficient and narrows the raw-type usage

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:102
  • Why it matters: - Root cause: MultiTableSinkAggregatedCommitter.java:102 declares List errCommitList = restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo); with a raw List.
  • Impact: cosmetic; the raw commitInfo argument at :93 has to stay raw because SinkAggregatedCommitter<?, ?> cannot accept a typed list, but the return value only needs size() and get(i) (:106-114, whose result goes into a Map<String, Object>), which List<?> provides without an unchecked warning.
  • Fix: change the declaration to List<?> errCommitList = ....
  • Suggested fix: Nit: since you are touching this line anyway, List<?> errCommitList = ... compiles fine here (only size()/get(i) are used below) and avoids extending the raw-type usage; the raw commitInfo argument above genuinely needs to stay raw, this one does not.
  • Severity: Low

Review conclusion

Conclusion: final approval remains pending on the previous comments

2. Remaining follow-ups

  • Issue 1: restoreCommit fails fast on the first table that throws; remaining tables' in-doubt XA transactions stay prepared and the propagated exception carries no table identifier
  • Issue 2: Architecture doc still shows a stale restoreCommit signature and says nothing about the multi-table wrapper forwarding it; this PR is what makes the hook reachable under Zeta, so the doc should be corrected alongside it
  • Issue 3: User-visible restore behaviour changes for JDBC XA and Iceberg under Zeta, but there is no release/upgrade note; the existing JDBC XA entry in incompatible-changes.md describes behaviour that was not actually reachable before this PR
  • Issue 4: This override also activates IcebergAggregatedCommitter.restoreCommit under Zeta for the first time; the PR only validated JDBC XA, and the existing Iceberg savepoint IT ran while that code was unreachable
  • Issue 5: The new test exercises a single table whose restoreCommit returns an empty list; the per-table split and the retry-list merge on the restore path are not covered
  • Issue 6: New test covers one table with an all-success return; the multi-table split and the positional retry-list merge on the restore path are not exercised
  • Issue 7: Explanatory // comment above an @Override and a raw List on the changed line; this package uses Javadoc for method contracts
  • Issue 8: Changed line keeps a raw List for the committer's return value; List<?> is sufficient and narrows the raw-type usage

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review conclusion

Reviewed commit: 73f6621

No source-level blocking issue found in the complete two-file scan. MultiTableSinkAggregatedCommitter.restoreCommit() now dispatches the per-table payload to SinkAggregatedCommitter.restoreCommit() rather than inheriting the interface default that delegates to commit(). The normal restore path reaches this override, while the ordinary commit path still selects commit(); the added test proves both dispatches.

Compatibility: no public signature or serialized payload changes.

Best change location: the aggregate committer is the correct boundary because it owns the table-to-committer fan-out. Moving this branch to each concrete committer would duplicate multi-table routing; the small shared helper keeps the two paths structurally aligned.

Validation performed: fetched the current PR ref; inspected the full diff, the implementation call path, and the new unit test. No local build/test was run because this review did not require compilation to establish the dispatch behavior.

CI gate: the current Build check is failing, so this is not yet ready to merge despite the source review. Please provide a green Build run.

Conclusion

Source review: no blocking finding. Final merge gate: wait for successful CI.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! This is a genuinely important fix, and the diagnosis behind it is exactly right — I traced it through the Zeta restore path and confirmed the problem is real on the affected path, not a theoretical one.

What this PR solves

When a job using a multi-table sink is restored from a checkpoint/savepoint, SinkAggregatedCommitterTask.restoreState calls aggregatedCommitter.restoreCommit(...). MultiTableSinkAggregatedCommitter did not override restoreCommit, so it fell through to SinkAggregatedCommitter's default (return commit(...)) — meaning every per-table committer received commit() on the restore path.

For connectors whose restoreCommit semantics genuinely differ from commit, this is not cosmetic:

  • JdbcSinkAggregatedCommitter.restoreCommit (seatunnel-connectors-v2/connector-jdbc/.../JdbcSinkAggregatedCommitter.java:97-107) runs replayRecoveredCheckpoint(...) against freshly collected XA recovery evidence — i.e. it replays already-resolved in-doubt transactions instead of committing prepared ones.
  • IcebergAggregatedCommitter.restoreCommit (seatunnel-connectors-v2/connector-iceberg/.../commit/IcebergAggregatedCommitter.java:64-76) explicitly checks filesCommitter.isAlreadyCommitted(checkpointId, allResults) and skips a checkpoint that was already committed.

Routing restore through commit() therefore risks re-committing transactions/checkshots that were already resolved, which is exactly the class of problem the two-phase protocol exists to prevent.

How it runs

Job restore from checkpoint / savepoint
  -> SinkCommitterTask / SinkAggregatedCommitterTask.restoreState(...) [SinkAggregatedCommitterTask.java:257-281]
      -> aggregatedCommitter.restoreCommit(aggregatedCommitInfos)   <-- restore path
          -> MultiTableSinkAggregatedCommitter
              BEFORE this PR: inherited default -> commit(...)  -> per-table sinkCommitter.commit(...)
              AFTER  this PR: commitPerTable(infos, restore=true)
                  -> per-table sinkCommitter.restoreCommit(...)    <-- each table gets its own restore semantics

Both overloads now share one private helper, so the routing logic cannot drift between the two paths again. abort is deliberately left untouched, which is correct — abort has no separate restore variant.

Review findings

I went through the whole diff and the call chain. No blocking issues.

Non-blocking notes, none of which I think warrant a re-roll:

  1. MultiTableSinkAggregatedCommitter.java:80 — the new private helper keeps the pre-existing raw List errCommitList / raw commitInfo locals. I know this is inherited from the original commit body and not introduced here, so I am not asking for it in this PR; a follow-up cleanup could parameterize the helper properly if you ever want it.
  2. The new comment above restoreCommit explains why the override exists, which is the important part. Good.

Tests

testRestoreCommitRoutesToTableRestoreCommit has real failure ability: with the override removed, the recorded calls would be commit[xid-1] twice instead of restoreCommit[xid-1], commit[xid-1], so the test genuinely guards the routing rather than just re-asserting the implementation. Asserting both restoreCommit then commit on the same row also pins the ordering, which is what makes the regression detectable. Test stability rating: stable — no timing waits, no shared state, no external resources.

Compatibility

Fully compatible. No API signature, config option, default value, or serialization format changes. Only the method dispatch on the restore path changes, and it changes toward the behaviour every per-table committer already implemented. Connector code needs no modification.

Conclusion: can be merged

From a source standpoint this is a precise, minimal fix at the right layer — the shared multi-table committer rather than any individual connector — with a test that would catch a regression. I'm happy to approve this one.

One note on CI: the Build check on this branch is currently red, but this branch is behind_by=25 versus dev and the last build ran on 2026-10-17. I can't read the external build log from here, and a 2-file seatunnel-api change that only adds a method override is very unlikely to be the cause. The lowest-cost next step is to sync with the latest dev and rerun the build; if it still fails, please paste the failing log here and I'll dig into it with you.

@ricky2129

Copy link
Copy Markdown
Collaborator Author

@davidzollo ^

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ricky2129 for the fix and for keeping the branch in sync. The only commit since my last review is a merge of dev (head 3c333b52ee, previous reviewed head 73f6621c27). Comparing the two heads, the PR's two files (MultiTableSinkAggregatedCommitter.java and its test) are untouched; the only overlapping dev change is in incompatible-changes.md (en/zh). I re-read the whole diff and the restore call chain on this head. I also owe you an apology: @SEZ9 posted a detailed review on the previous head (eight points) and my last round did not fold those in. I have checked each one against the code below, and I now agree with most of them as non-blocking follow-ups. I did not compile or run anything.

What Problem Does This PR Solve?

  • User pain point: Under Zeta every sink runs inside MultiTableSink, so on restore SinkAggregatedCommitterTask calls MultiTableSinkAggregatedCommitter.restoreCommit. That class did not override it, so the interface default (return commit(...), SinkAggregatedCommitter.java:42-45) ran, and a connector's own restoreCommit was never reached. For the JDBC XA sink (JdbcSinkAggregatedCommitter.restoreCommit, #11569) this means a restore re-commits XIDs that were usually already committed, MySQL answers XAER_NOTA, and the job cannot restore (#12805).
  • Fix approach: Override restoreCommit and route it through a shared commitPerTable(infos, restore) helper that keeps the existing per-table split and error-list merge and only switches between restoreCommit and commit.
  • One-sentence summary: The multi-table wrapper now forwards the restore call to each table's own restoreCommit.

1. Code Change Review

1.1 Core Logic Analysis

Runtime path (restore under Zeta):

SinkAggregatedCommitterTask.restoreState()   (SinkAggregatedCommitterTask.java:~260-281)
  -> aggregatedCommitter.restoreCommit(deserialized infos)   (:~275)
     -> MultiTableSinkAggregatedCommitter.restoreCommit()    (MultiTableSinkAggregatedCommitter.java:80-84)  [new override]
        -> commitPerTable(infos, true)                       (:86-119)
           -> per sinkIdentifier: pick that table's entries (:93-101)
           -> restore ? sinkCommitter.restoreCommit(...) : sinkCommitter.commit(...)   (:102-105)
           -> merge non-empty retry lists by position into errorList (:106-115)
  -> non-empty result -> CheckpointException(AGGREGATE_COMMIT_ERROR)
  • The normal restore path reaches the change: every sink goes through MultiTableSink on Zeta, and restoreState is the only production caller of restoreCommit (checked with a search of the non-test sources). The ordinary commit path still selects commit() (:75), and the new test pins both dispatches in order.
  • abort and close are correctly left alone; there is no restore variant of them.
  • Only two production connectors override restoreCommit: JdbcSinkAggregatedCommitter and IcebergAggregatedCommitter. So the blast radius of this override is exactly those two, under Zeta.
  • The shared helper is the right level: the wrapper owns the table fan-out, and a per-connector workaround would duplicate that routing.

1.2 Compatibility Impact

API, config, serialization and state formats are unchanged, so it is fully compatible at the contract level. It does change restore behavior under Zeta for the two connectors above: JDBC XA restores stop failing with XAER_NOTA and start following the recovery-order rules already described in incompatible-changes.md (the "JDBC XA restore now uses recovery-order evidence and fail-closed gaps" entry), and Iceberg restores now skip checkpoints that isAlreadyCommitted reports instead of re-running commitFiles. Both are moves toward what those committers were written to do, but they are user-visible (Issues 3 and 4).

1.3 Performance / Side-Effect Analysis

No new per-record cost; the restore runs once per task start. For tables with no restored entries the call still receives an empty list, which is the same shape as the existing commit() path (JDBC restoreCommit only calls tryOpen() in that case, like the commit path).

1.4 Error Handling and Logging

Issue 1: Restore fails fast on the first table that throws, and the error does not name the table (raised by @SEZ9, I agree)

  • Location: MultiTableSinkAggregatedCommitter.java:102-105
  • Problem: the loop over aggCommitters.keySet() has no per-table handling, so the first exception from any table's restoreCommit (for JDBC, tryOpen() failing or the fail-closed XID gap check) unwinds the loop and the later tables are not reconciled in that attempt. The surfaced exception carries no sinkIdentifier. abort() and close() in the same class already catch per table, log, keep the first throwable and rethrow after the loop.
  • Potential risk: moderate rather than severe. The job fails and is retried from the same checkpoint, and both committers' restore paths are meant to be idempotent, so the skipped tables are reconciled on the next attempt. The cost is slower diagnosis and a restore that cannot make partial progress while one table keeps failing. commit() has the same shape today, so this is not a regression.
  • Best improvement: apply the abort() pattern at least to the restore branch: log with sinkIdentifier, remember the first throwable, continue, and rethrow at the end with the identifier in the message.
  • Severity: Medium (non-blocking; I would accept it as a follow-up)
  • Raised by another reviewer: Yes (@SEZ9, Issue 1)

Issue 2: Architecture doc shows a stale restoreCommit signature (raised by @SEZ9, I agree)

  • Location: docs/en/architecture/api-design/sink-architecture.md (the SinkAggregatedCommitter snippet, default void restoreCommit(...) throws IOException {})
  • Problem: the real method returns List<AggregatedCommitInfoT> and defaults to commit(...). A connector author following the doc would write a void method that overrides nothing. Since this PR is what makes the hook reachable under Zeta, it is a natural place to fix it, and to add one sentence that the multi-table wrapper forwards restoreCommit per table.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 2)

Issue 3: No upgrade note for the user-visible restore change (raised by @SEZ9, I agree)

  • Location: docs/en/introduction/concepts/incompatible-changes.md and the zh counterpart, under ## dev
  • Problem: the JDBC XA restore semantics are already documented there as if they applied, but under Zeta they only take effect with this PR, and Iceberg restores start skipping already-committed checkpoints. The PR description mentions only JDBC.
  • Best improvement: a short entry saying the multi-table wrapper now forwards restoreCommit, naming JDBC XA and Iceberg, and mention Iceberg in the PR's user-facing-change section.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 3)

Issue 4: Iceberg's restoreCommit becomes reachable under Zeta for the first time (raised by @SEZ9, I agree)

  • Location: MultiTableSinkAggregatedCommitter.java:83; IcebergAggregatedCommitter.java:64-78
  • Problem: the end-to-end validation covered only MySQL-CDC to JDBC XA. The Iceberg savepoint recovery IT is Zeta-only and its Javadoc says it exercises restoreCommit, but until now that method could not run there. The iceberg-connector-it job is in this PR's CI matrix, so the answer will come from CI; please check it explicitly when it finishes rather than relying on the aggregate status.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 4)

Issue 5: The new test covers one table with an empty return; the split and the retry-list merge on the restore path are not exercised (raised by @SEZ9 twice, I agree)

  • Location: MultiTableSinkAggregatedCommitterTest.java:75-117 (testRestoreCommitRoutesToTableRestoreCommit)
  • Problem: the test is a real regression guard for the routing bug (removing the override makes it record commit[xid-1] twice, so it turns red). But because the filtering and positional errorList merge now live in the shared helper, one more case would make the restore path safe to refactor: two tables where one restoreCommit returns a non-empty retry list, asserting each stub saw only its own entries and the returned MultiTableAggregatedCommitInfo holds the retry entry under the right identifier.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issues 5 and 6)

Issue 6: Style nits (raised by @SEZ9, Issues 7 and 8)

  • Location: MultiTableSinkAggregatedCommitter.java:78-79 and :102
  • Problem: the rationale for the override is a // comment above @Override; a Javadoc block would show up in the IDE and matches how the interface documents its contract. The raw List errCommitList is inherited from the old commit() body, and List<?> would work since only size() and get(i) are used. Neither needs to block the PR.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9)

2. Code Quality Assessment

2.1 Coding Standards

Small, focused diff; the extracted helper keeps the two paths structurally identical, so they cannot drift apart. No new classes, so no license header question. See Issue 6 for the comment form.

2.2 Test Coverage and Test Stability

testRestoreCommitRoutesToTableRestoreCommit asserts the exact ordered call list restoreCommit[xid-1], commit[xid-1], so removing the override, swapping the flag, or routing restore back to commit fails it; the author also reports it fails on dev with a clear message. It uses an in-memory stub with no timing or shared state. Stability rating: Stable. The gap is multi-table coverage (Issue 5). The cross-module risk (Iceberg and JDBC under Zeta) is covered only by connector ITs, which are running in CI (Issue 4).

2.3 Documentation Updates

Not updated yet: the architecture doc (Issue 2) and incompatible-changes.md en/zh (Issue 3).

3. Architectural Soundness

The fix sits at the right layer, the multi-table wrapper, and uses the existing interface hook rather than adding a new one. The only structural trade-off is that commit() and restoreCommit() now share a fail-fast loop (Issue 1); making that loop per-table resilient is the one improvement I would consider worth doing in this class.

4. Issue Summary

Number Issue Location Severity Raised by another reviewer
1 Fail-fast restore loop, error does not name the table MultiTableSinkAggregatedCommitter.java:102-105 Medium Yes (@SEZ9)
2 Stale restoreCommit signature in architecture doc sink-architecture.md Low Yes (@SEZ9)
3 No incompatible-changes note for JDBC XA and Iceberg restore change incompatible-changes.md (en/zh) Low Yes (@SEZ9)
4 Iceberg restoreCommit newly reachable under Zeta, check the Iceberg IT MultiTableSinkAggregatedCommitter.java:83 Low Yes (@SEZ9)
5 Test covers one table with an empty return MultiTableSinkAggregatedCommitterTest.java:75-117 Low Yes (@SEZ9)
6 Comment form and raw List MultiTableSinkAggregatedCommitter.java:78-79, 102 Low Yes (@SEZ9)

5. Merge Recommendation

CI for head 3c333b52ee (fork run 39551627031, still running when I looked; apache Build is pending): unit-test is red on all four lanes with LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled in seatunnel-transforms-v2 (InvalidClassException ... AbstractMultiCatalogTransform; local class incompatible). This PR changes only seatunnel-api sink code and a test, and the same failure appears on other open PRs that are 0 commits behind dev, so it is not caused by this diff. My reading of the logs is that a hard-coded legacy stream in a test merged with #12194 no longer matches the serialVersionUID after #12804; I did not find a fix PR. The branch is 0 commits behind dev and mergeable.

Conclusion: Ready to merge after fixes

Blockers

  • CI must be green on the final head; the red unit-test job needs a fix on dev first, then rerun only the failed jobs. Please also confirm iceberg-connector-it and the JDBC ITs pass. I see no source-side blocker.

Recommended fixes (non-blocking)

  • Issue 1: per-table error handling with the table name in the message, at least for restore.
  • Issues 2 and 3: correct the architecture doc snippet and add a short incompatible-changes.md entry (en/zh).
  • Issue 5: one two-table test case.
  • Issue 6: Javadoc instead of the // comment, List<?> for the retry list.

Overall assessment: a precise, minimal fix at the right layer for a real restore failure on Zeta, with a regression test that can fail. A committer approval is still needed; I am not approving until CI is green.

@DanielLeens

Copy link
Copy Markdown
Contributor

A CI-status correction on unchanged head 3c333b52ee05a91974f4166454c8ef66abf5e193: my previous note described a queued/pending Build. The current Build is now failure, so the old pending guidance is obsolete. Failed job families: Run / unit-test, Run / jdbc-connectors-it-part-4.

Concrete inspected log evidence (one representative JDK/OS per failed family; this does not claim every matrix leg has the identical cause):

Upstream/next-step check:

The archived LLM fixture is tracked in #12929; proposed fix #12938 remains open. Latest dev (99ea16b9d6bdce452d4c4955581ccc7236a81bbd) still has no explicit historical UID on AbstractMultiCatalogTransform. Syncing today will not fix that observed failure. Once the fix lands in dev, sync and rerun the affected failed jobs. Keep unrelated transform-serialization changes out of this PR.

The missing Maven wrapper class is a bootstrap failure, not an executed connector assertion. No matching base-branch wrapper correction was identified. A targeted retry of that failed job after download/bootstrap availability recovers is the useful diagnostic; do not add product dependencies to compensate.

My previous source-level conclusion remains unchanged: no outstanding source blocker from my side. This is a CI-status follow-up, not a fresh full code review or formal approval. The branch is ahead 6, behind 9, compare diverged against dev; this drift is recorded independently, not used as a generic sync request. A successful required Build and write-capable maintainer approval remain merge gates. Thanks for the contribution and for keeping the fix focused.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for your patience. The upstream status has changed since my preceding note: #12938 merged into dev at 2026-10-22 10:26 UTC (merge cc54bb433357b4cb45db9cd5d0743589c3111b79). I checked that current dev contains the merge and that its diff restores the historical AbstractMultiCatalogTransform serialization UID and makes the construction-only config transient. My earlier instruction to wait for that fix is now superseded.

The archived-wrapper LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled / InvalidClassException is the shared unit-test failure identified in the preceding review (affected job). This head is still 3c333b52ee05a91974f4166454c8ef66abf5e193; the current dev comparison is diverged, ahead 6 / behind 11. Please sync with the latest dev and rerun the affected unit checks first, plus any stage whose log showed the same archived-wrapper error. Keep unrelated transform-serialization patches out of this PR. This is a targeted remedy for that known upstream failure, not a claim that syncing fixes every failed stage.

Other failed job families in the same head's run are jdbc-connectors-it-part-4. Their causes/results remain separate; this upstream patch does not establish that they pass. My previous source-level conclusion is unchanged. Required CI and the final write-capable maintainer review remain gates. This is a CI-status follow-up only, with no new source findings or fresh full-review claim.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ricky2129 for the focused fix. I re-reviewed the latest head d9e1a8a06722 in full. Compared with my previous round (3c333b52ee) the two PR files are byte-for-byte unchanged (the new head is another dev merge), so every point from my last review is a carryover. I again traced the full restore chain through the engine and the SupportMultiTableSinkWriter/committer contract; I found no new source-level blocker. I did not run builds or tests; the notes below are from reading source and CI results.

What Problem Does This PR Solve?

  • User pain point: Under Zeta every sink is wrapped in MultiTableSink, so on restore the engine calls MultiTableSinkAggregatedCommitter.restoreCommit. The class did not override it, so the interface default (SinkAggregatedCommitter.java:42-45, return commit(...)) ran and a connector's own restoreCommit was never reached. For the JDBC XA sink the restore re-commits XIDs that were already committed, MySQL answers XAER_NOTA, and the job cannot restore (#12805).
  • Fix approach: Override restoreCommit in the wrapper and route it through a shared commitPerTable(infos, restore) helper that keeps the per-table split and error-list merge and only switches between restoreCommit and commit.
  • One-sentence summary: The multi-table wrapper now forwards restore to each table's own restoreCommit instead of silently downgrading it to commit.

1. Code Change Review

1.1 Core Logic Analysis

Changed: MultiTableSinkAggregatedCommitter.java (commit() now delegates to commitPerTable(infos, false), new restoreCommit() delegates to commitPerTable(infos, true)) and one new unit test.

// before: restoreCommit not overridden -> interface default -> commit()
List errCommitList = sinkCommitter.commit(commitInfo);
// after
List errCommitList = restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo);

Runtime path on restore:

SinkAggregatedCommitterTask.restoreState()  SinkAggregatedCommitterTask.java:260-281
  -> aggregatedCommitter.restoreCommit(deserialized infos)  :275
     -> MultiTableSinkAggregatedCommitter.restoreCommit()  [new]
        -> commitPerTable(infos, true)
           -> per sinkIdentifier: pick that table's entries from MultiTableAggregatedCommitInfo
           -> table committer.restoreCommit(entries)   (JdbcSinkAggregatedCommitter.java:97, IcebergAggregatedCommitter.java:64-78)
           -> merge non-empty retry lists by position into errorList
  -> non-empty result -> CheckpointException(AGGREGATE_COMMIT_ERROR)  :276-278

Findings: the normal Zeta restore path hits this change (restoreState is the only production caller of restoreCommit). The normal commit path is unchanged and still calls commit(). The table split uses the same sink identifier keys that combine() produced, so restored state deserialized from a checkpoint maps to the same table committers. Only two production connectors override restoreCommit (JDBC and Iceberg), so the blast radius is exactly those two under Zeta. The helper is the right level; a per-connector workaround would duplicate the fan-out. Logic is correct.

1.2 Compatibility Impact

Partially incompatible (behavioral, not contract). Serialization, state formats, config and APIs are unchanged, and connectors without a restoreCommit override behave exactly as before. But restore behavior under Zeta changes for JDBC XA (follows the recovery-order and fail-closed-gap rules already documented) and for Iceberg (restores now skip checkpoints reported by isAlreadyCommitted instead of re-running commitFiles). Both are moves toward what those committers were written to do, but they are user-visible and are not yet recorded in the upgrade notes (Issue 3).

1.3 Performance / Side-Effect Analysis

No per-record cost; restore runs once per committer task start. For tables with no restored entries the call still receives an empty list, the same shape as the existing commit() path. No new threads, buffers, or retained state.

1.4 Error Handling and Logging

Issue 1: Restore fails fast on the first failing table and the error does not name the table (carryover from my last round)

  • Location: MultiTableSinkAggregatedCommitter.java commitPerTable loop (the restoreCommit dispatch line)
  • Problem description: no per-table handling, so the first exception (for JDBC, tryOpen() failing or the fail-closed XID gap check) unwinds the loop; later tables are not reconciled in that attempt and the surfaced exception lacks the sinkIdentifier. abort() and close() in the same class already catch per table, log, keep the first throwable and rethrow after the loop.
  • Potential risk: the job fails and retries from the same checkpoint, and both restore paths are meant to be idempotent, so this is slower diagnosis rather than data loss. commit() has the same shape today, so it is not a regression.
  • Best improvement: apply the abort() pattern at least to the restore branch: log with sinkIdentifier, remember the first throwable, continue, rethrow at the end with the identifier in the message.
  • Severity: Medium (non-blocking, acceptable as a follow-up)
  • Raised by another reviewer: Yes (@SEZ9, Issue 1)

Issue 2: Architecture doc shows a stale restoreCommit signature

  • Location: docs/en/architecture/api-design/sink-architecture.md (SinkAggregatedCommitter snippet)
  • Problem description: the doc shows a void method with an empty default; the real method returns List<AggregatedCommitInfoT> and defaults to commit(...).
  • Potential risk: a connector author following the doc writes a void method that overrides nothing.
  • Best improvement: fix the snippet and add one sentence that the multi-table wrapper forwards restoreCommit per table.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 2)

Issue 3: No upgrade note for the user-visible restore change

  • Location: docs/en/introduction/concepts/incompatible-changes.md and the zh counterpart, under ## dev
  • Problem description: JDBC XA restore semantics are documented as if already in effect, but under Zeta they only take effect with this PR; Iceberg restores also start skipping committed checkpoints. The PR description mentions only JDBC.
  • Potential risk: upgrading users are surprised by changed restore behavior.
  • Best improvement: add a short en/zh entry naming JDBC XA and Iceberg; mention Iceberg in the PR's user-facing-change section.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 3)

Issue 4: Iceberg restoreCommit becomes reachable under Zeta for the first time

  • Location: MultiTableSinkAggregatedCommitter.java restoreCommit override; IcebergAggregatedCommitter.java:64-78
  • Problem description: the end-to-end validation covered only MySQL-CDC to JDBC XA. IcebergSinkParallelCommitIT.testRecoveryFromSavepointProducesNoDuplicateSnapshots is Zeta-only and says it exercises restoreCommit, which could not run there before.
  • Potential risk: an untested behavior change for a second connector.
  • Best improvement: confirm the Iceberg connector IT passes on the final head and mention Iceberg in the description.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issue 4)

Issue 5: The new test covers one table with an empty return

  • Location: MultiTableSinkAggregatedCommitterTest.java:75-117
  • Problem description: the per-table split and the positional retry-list merge on the restore path are not exercised.
  • Potential risk: a later refactor of the shared helper could break restore-path merging unnoticed.
  • Best improvement: add a two-table case where one restoreCommit returns a non-empty retry list; assert each stub saw only its own entries and the returned info holds the retry entry under the right identifier.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issues 5 and 6)

Issue 6: Comment form and raw List

  • Location: MultiTableSinkAggregatedCommitter.java the // comment above restoreCommit and the raw List errCommitList
  • Problem description: the rationale is a // comment above @Override; the interface documents its contract with Javadoc. The raw list is inherited from the old body; List<?> would do.
  • Potential risk: none functionally; readability only.
  • Best improvement: use a Javadoc block and List<?>.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, Issues 7 and 8)

2. Code Quality

2.1 Coding Standards

Small, focused diff; the shared helper keeps the two paths structurally identical so they cannot drift. The new nontrivial helper commitPerTable has no Javadoc explaining the restore flag; this is covered under Issue 6 (Low).

2.2 Test Coverage and Test Stability

Rating: Stable. testRestoreCommitRoutesToTableRestoreCommit asserts the exact ordered calls restoreCommit[xid-1], commit[xid-1], so removing the override or routing restore back to commit turns it red. It is in-memory with no timing. Gap: multi-table coverage (Issue 5). CI status on the current head is not green (see section 5), so I cannot claim the Iceberg and JDBC ITs have validated the cross-module effect.

2.3 Documentation

Not updated: architecture doc (Issue 2) and incompatible-changes.md en/zh (Issue 3).

3. Architectural Soundness

  • 3.1 Precise fix, at the right layer (the wrapper), using the existing interface hook.
  • 3.2 Maintainability: good; one shared helper. The shared fail-fast loop (Issue 1) is the one thing worth hardening.
  • 3.3 Extensibility: any future connector overriding restoreCommit is automatically honored under Zeta.
  • 3.4 Historical-version compatibility: no change to serialized commit info or checkpoint formats, so states written by older versions restore through the same keys; only the invoked method changes for JDBC XA and Iceberg.

4. Issue Summary

Number Issue Location Severity
1 Fail-fast restore loop, error does not name the table MultiTableSinkAggregatedCommitter.java commitPerTable Medium
2 Stale restoreCommit signature in architecture doc sink-architecture.md Low
3 No incompatible-changes note (JDBC XA, Iceberg) incompatible-changes.md (en/zh) Low
4 Iceberg restoreCommit newly reachable under Zeta MultiTableSinkAggregatedCommitter.java; IcebergAggregatedCommitter.java:64-78 Low
5 Test covers one table with an empty return MultiTableSinkAggregatedCommitterTest.java:75-117 Low
6 Comment form and raw List MultiTableSinkAggregatedCommitter.java Low

5. Merge Recommendation

CI on head d9e1a8a06722: the apache-side Build check is failing. In the fork run (Build 40347152059) the Run / all-connectors-it-3 (11, ubuntu-latest) leg failed after about 2.5h with "SeaTunnel job executed failed" annotations, while the 17 leg of the same job passed, and several downstream jobs were skipped or cancelled. I could not retrieve the full failure log, so I cannot attribute the failing test; the diff touches only seatunnel-api sink code and a unit test, so a relation is not evident, but I am not asserting it is unrelated either. Please rerun only the failed job and check its log.

Conclusion: Ready to merge after fixes

Blockers

  • CI must be green on the final head (rerun the failed all-connectors-it-3 (11) job and confirm the skipped or cancelled stages, including the Iceberg and JDBC ITs, complete). I see no source-side blocker.

Non-blocking fixes

  • Issue 1: per-table error handling with the table name, at least for restore.
  • Issues 2 and 3: correct the architecture doc snippet and add the en/zh incompatible-changes.md entry.
  • Issue 5: one two-table test case.
  • Issue 6: Javadoc and List<?>.
  • Issue 4: mention Iceberg in the PR description.

Overall assessment: a small, correct, well-placed fix with a real regression test; the remaining items are hardening and documentation. Alternatives: a per-connector workaround in the JDBC committer would not help other connectors and duplicates the fan-out; the wrapper override is the better choice. Thanks again for the contribution.

@SEZ9

SEZ9 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Re-checked d9e1a8a06722 against the previous round on 3c333b52ee: the two PR files are unchanged (the new head is another dev merge), so the earlier points still stand. The core change looks right — the wrapper now forwards restoreCommit per table instead of letting the interface default downgrade it to commit — and I found no new blocker. Remaining asks, in priority order:

Should be addressed before merge

  1. Fail-fast in restoreCommit (MEDIUM, Robustness). In commitPerTable(infos, true), the first table whose restoreCommit throws aborts the loop, so the remaining tables' in-doubt XA transactions stay prepared, and the propagated exception carries no table identifier. Please either continue over the remaining tables and rethrow an aggregated exception afterwards, or at minimum wrap the exception with the sinkIdentifier so the failing table is visible in the log.

  2. Architecture doc (MEDIUM, Docs). The architecture doc still shows a stale restoreCommit signature and does not mention that the multi-table wrapper forwards it. Since this PR is what makes the hook reachable under Zeta, please correct the signature and add a sentence on the wrapper's forwarding behaviour in the same PR.

Nice to have / can be a follow-up if you prefer, but please say so

  1. Release/upgrade note (LOW, Docs). Restore behaviour for JDBC XA and Iceberg under Zeta changes with this PR. Please add a note, and fix the existing JDBC XA entry in incompatible-changes.md, which currently describes behaviour that was not actually reachable before this change.

  2. Iceberg restore path (LOW, Functional). This override also activates IcebergAggregatedCommitter.restoreCommit under Zeta for the first time, while the PR only validated JDBC XA. Could you run the existing Iceberg savepoint IT locally against this branch and report the result here? That's enough for me if it passes.

  3. Unit test coverage (LOW, Test). The new test uses a single table whose restoreCommit returns an empty list. Please add one case with two or more tables where at least one returns a non-empty retry list, so the per-table split and the positional retry-list merge on the restore path are actually exercised.

  4. Style (LOW). Replace the // comment above the overriding method with Javadoc (consistent with the rest of this package), and change the raw List on the changed line to List<?>.

If you'd rather defer 3–6, just note that in a reply and I'll track them separately; 1 and 2 I'd like in this PR. Thanks for the focused fix.

@nzw921rx

Copy link
Copy Markdown
Member

@ricky2129 please rerun failed job?

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ricky2129 for the focused fix. I re-reviewed the latest head c3437e23a797 in full. Compared with the previous round on d9e1a8a06722, the PR's own files are unchanged (git diff d9e1a8a06722..c3437e23a797 -- seatunnel-api is empty; the new head is another dev merge), so none of the earlier points were addressed yet and every issue below is a carryover from my last review. This is a refresh of the same conclusion, not new findings. I read source and CI results only; I did not build or run tests.

What Problem Does This PR Solve?

  • User pain point: Under Zeta every sink is wrapped in MultiTableSink, so on restore the engine calls MultiTableSinkAggregatedCommitter.restoreCommit. The class did not override it, so the interface default (SinkAggregatedCommitter.java:42, which calls commit(...)) ran and a connector's own restoreCommit was never reached. For the JDBC XA sink this re-commits XIDs that were already committed, the database answers XAER_NOTA, and the job cannot restore (#12805).
  • Fix approach: Override restoreCommit in the wrapper and route it through a shared commitPerTable(infos, restore) helper that keeps the per-table split and retry-list merge and only switches between restoreCommit and commit.
  • One-sentence summary: The multi-table wrapper now forwards restore to each table's own restoreCommit instead of silently downgrading it to commit.
  • Example: A job with tables t1 and t2 on the JDBC XA sink is restored from a checkpoint; previously t1/t2 XIDs went through commit, now they go through JdbcSinkAggregatedCommitter.restoreCommit with its recovery-order handling.

1. Code Change Review

1.1 Core Logic Analysis

Changed: MultiTableSinkAggregatedCommitter.java (commit() delegates to commitPerTable(infos, false), new restoreCommit() delegates to commitPerTable(infos, true), dispatch at lines 102-105) and one new unit test.

// before: restoreCommit not overridden -> interface default -> commit()
List errCommitList = sinkCommitter.commit(commitInfo);
// after
List errCommitList = restore ? sinkCommitter.restoreCommit(commitInfo) : sinkCommitter.commit(commitInfo);

Runtime path on restore:

SinkAggregatedCommitterTask.restoreState()   (SinkAggregatedCommitterTask.java:275)
  -> aggregatedCommitter.restoreCommit(deserialized infos)
     -> MultiTableSinkAggregatedCommitter.restoreCommit()          [new, lines 80-84]
        -> commitPerTable(infos, true)                             [lines 86-119]
           -> per sinkIdentifier: select that table's entries
           -> table committer.restoreCommit(entries)  (JdbcSinkAggregatedCommitter.java:97, IcebergAggregatedCommitter.java:64)
           -> merge non-empty retry lists by position into errorList
  -> non-empty result -> checkpoint exception

Findings: the normal Zeta restore path reaches this change (restoreState is the only production caller of restoreCommit). The normal commit path still calls commit() and is behaviorally unchanged. Table keys are the same sinkIdentifier strings that combine() produced, so restored state maps to the same table committers. Only JDBC and Iceberg override restoreCommit in production, so the behavior change is limited to those two under Zeta. The fix is at the right layer. Logic is correct.

1.2 Compatibility Impact

Partially incompatible (behavioral, not contract). Serialization, state format, config and public API signatures are unchanged, and connectors without a restoreCommit override behave exactly as before. Restore behavior under Zeta does change for JDBC XA (it now follows the documented recovery-order and fail-closed-gap rules) and for Iceberg (it now uses its own restore logic instead of re-running the commit). Both move toward what those committers were written to do, but they are user-visible and are not recorded in the upgrade notes (Issue 3).

1.3 Performance / Side Effects

No per-record cost; restore runs once at committer task start. No new threads, buffers or retained state. Tables with no restored entries still receive an empty list, the same shape as the existing commit() path.

1.4 Error Handling and Logging

Issue 1: Restore fails fast on the first failing table and the error does not name the table

  • Location: MultiTableSinkAggregatedCommitter.java:102-105 (inside the commitPerTable loop)
  • Problem: the first exception from a table's restoreCommit unwinds the loop, so later tables are not reconciled in that attempt and the surfaced exception lacks the sinkIdentifier. abort() and close() in this class already catch per table, log, keep the first throwable and rethrow after the loop.
  • Risk: the job fails and retries from the same checkpoint (restore paths are meant to be idempotent), so this costs diagnosis time rather than data. commit() has the same shape today, so it is not a regression of this PR.
  • Best improvement: at least for the restore branch, catch, log with sinkIdentifier, and rethrow with the identifier in the message (continuing over the remaining tables and rethrowing the first throwable afterwards, as abort() does, is the stronger option).
  • Severity: Medium (non-blocking, acceptable as a follow-up if agreed)
  • Raised by another reviewer: Yes (@SEZ9, item 1)

2. Code Quality

2.1 Standards

Issue 5: Comment form and raw List

  • Location: MultiTableSinkAggregatedCommitter.java:78-79 and line 102
  • Problem: the explanation of why restoreCommit is overridden is a // comment, and the new commitPerTable helper has no Javadoc describing the restore flag. The changed line keeps a raw List.
  • Best improvement: use Javadoc on both methods, and List<?> on the changed line.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, item 6)

2.2 Tests and Stability

Issue 4: The new test covers one table with an empty retry list

  • Location: MultiTableSinkAggregatedCommitterTest.java (testRestoreCommitRoutesToTableRestoreCommit)
  • Problem: it proves the override routes to restoreCommit (removing the override or the restore branch turns it red), but the per-table split and positional retry-list merge on the restore path are not exercised.
  • Best improvement: add one case with two or more tables where at least one restoreCommit returns a non-empty list, asserting the merged output positions and that each table sees only its own entries.
  • Severity: Medium (this is a seatunnel-api class with a state-recovery role, so I would like the merge covered)
  • Raised by another reviewer: Yes (@SEZ9, item 5)

Stability rating: Stable (in-memory, deterministic, no sleeps, ports or shared resources).

2.3 Docs

Issue 2: Architecture doc shows a stale restoreCommit signature

  • Location: docs/en/architecture/api-design/sink-architecture.md:531
  • Problem: it shows default void restoreCommit(...) {}, while the real method returns List<AggregatedCommitInfoT> and defaults to commit(...). The doc says nothing about the multi-table wrapper forwarding it.
  • Risk: a connector author following the doc writes a void method that overrides nothing.
  • Best improvement: fix the snippet (en, and mention in zh sink-architecture.md:201 if it states the semantics) and add one sentence that the multi-table wrapper forwards restoreCommit per table.
  • Severity: Medium
  • Raised by another reviewer: Yes (@SEZ9, item 2)

Issue 3: No upgrade note for the user-visible restore change

  • Location: docs/en/introduction/concepts/incompatible-changes.md (existing JDBC XA entry around line 316) and the zh counterpart
  • Problem: restore behavior for JDBC XA and Iceberg under Zeta changes with this PR, and the existing JDBC XA entry describes behavior that was not reachable through the multi-table wrapper before.
  • Best improvement: add a short note, or state in the PR that it is deferred.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, item 3)

Issue 6: Iceberg restore path is activated under Zeta for the first time and only JDBC XA was validated

  • Location: PR description / IcebergAggregatedCommitter.java:64
  • Best improvement: run the existing Iceberg savepoint IT against this branch (or cite the CI result) and mention Iceberg in the PR description.
  • Severity: Low
  • Raised by another reviewer: Yes (@SEZ9, item 4)

3. Architecture

  • 3.1 Precise fix: it corrects the actual root cause (the missing override in the generic wrapper) rather than patching individual connectors.
  • 3.2 Maintainability: good; one shared helper keeps the commit and restore paths structurally identical.
  • 3.3 Extensibility: the boolean flag is acceptable for two paths; no need to generalize.
  • 3.4 Contract: the SupportMultiTableSinkWriter/committer contract is untouched; no new registration is needed.

4. Issue Summary

# Issue Location Severity Blocking
1 Fail-fast restore loop, error lacks table id MultiTableSinkAggregatedCommitter.java:102-105 Medium No
2 Stale restoreCommit signature in architecture doc docs/en/architecture/api-design/sink-architecture.md:531 Medium Yes
3 No upgrade note docs/en/introduction/concepts/incompatible-changes.md Low No
4 Test lacks multi-table / non-empty retry coverage MultiTableSinkAggregatedCommitterTest.java Medium Yes
5 Javadoc and List<?> MultiTableSinkAggregatedCommitter.java:78,102 Low No
6 Iceberg restore not validated PR description Low No

CI: the head's Build check concluded timed_out. In the contributor fork run, 83 jobs succeeded, 11 were skipped and 2 were cancelled (transform-v2-it-part-2 (17, ubuntu-latest) and all-connectors-it-3 (11, ubuntu-latest)); the run was cancelled at the time limit rather than failing an assertion. This diff only touches seatunnel-api sink classes and a unit test, so these cancellations are not related to it. Please re-run the two cancelled jobs from the fork's Actions tab. The branch is 3 commits behind dev and mergeable is true, with no conflicts.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

The source change is correct and minimal, and I found no source-level defect in it. Existing review state: there is no maintainer approval or change request recorded yet, so merge readiness still depends on a write-capable maintainer review plus green CI.

Blockers (before merge):

  • Issue 2: correct the architecture doc signature and mention the wrapper's forwarding.
  • Issue 4: add a two-table test with a non-empty retry list on the restore path.
  • CI: re-run the two cancelled jobs until the Build check is green.

Non-blocking recommendations:

  • Issue 1: name the failing table in the restore error (and ideally keep reconciling the remaining tables).
  • Issue 3, Issue 5, Issue 6, as described above; if you would rather defer them, a one-line reply is enough and they can be tracked separately.

Thanks again for the clear root-cause analysis; this is close.

@nzw921rx nzw921rx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

https://github.com/ricky2129/seatunnel/actions/runs/40507160077/job/122200579062

CI has been cancelled due to timeout, PR has been fixed accurately. I have conducted complete local verification and will proceed with bypass

@nzw921rx

Copy link
Copy Markdown
Member

Thanks for the focused fix. I checked the restore call chain and ran local regression tests on PR head c3437e23a79733fe996fdcb14d647ce596488178, with dev at 403efeee0b3806c77e55c38368abdd41fbf828bd merged locally.

The forwarding change is correct: normal commits still call each table's commit(); restores now call each table's restoreCommit(). Committers without an override continue to use the interface default, which delegates to commit().

Unit tests and build checks

Scope Result
API unit tests 410 passed
JDBC XA unit tests 28 passed
Iceberg unit tests 131 passed
MySQL CDC configuration/serialization tests 11 passed
Supplemental multi-table wrapper boundary tests 8 passed
Runtime dependency build 47-module build passed
API formatting and verification Spotless check and Maven verify passed; tests were run separately as listed above

All 588 tests listed above completed without failures, errors, or skips.

The eight supplemental wrapper tests covered:

  • Per-table routing, input ordering, and missing/null table entries.
  • Unequal, non-empty retry lists, preserving the correct table identifiers.
  • The default restoreCommit() implementation delegating to commit().
  • Normal commit() not invoking a custom restore override.
  • Exceptions remaining visible, with the existing fail-fast behavior.
  • Empty restored state.
  • Repeated restore calls preserving each table's batch sequence.
  • Serialization round-trips preserving exact table identifiers.

These supplemental tests were run locally; they have not been added to this PR.

Real MySQL recovery tests

The tests used MySQL 8.0.43 and actual MySQL-CDC → JDBC jobs. Two Master instances and one Worker instance were started in one JVM and communicated over loopback networking. This validates actual connector and engine execution, but is not a multi-process or multi-host deployment test.

The successful job scenarios included initial snapshots, streaming inserts/updates/deletes, checkpoint cancellation and restore, and two further savepoint/restore cycles. Source and target rows were compared after recovery and subsequent DML. Transactional target audit triggers also checked that successful XA restores did not replay writes.

For the negative controls, the dev wrapper implementation was substituted into the same runtime while keeping the remaining components unchanged.

Scenario Dev control PR result
Two-table XA state containing already-committed transactions Reproduced XAER_NOTA Repeated restore three times successfully
XA recovery matrix: normal commits, all-prepared transactions, committed-prefix/prepared-suffix recovery, unrelated prepared transactions, inconsistent recovery gaps, and empty state Confirmed the original restore failure separately 13 checks passed, including the expected rejection of an inconsistent gap
Single-table JDBC XA Restore failed with XAER_NOTA Three restore cycles and subsequent DML passed; final 32 rows matched
Three-table JDBC without XA, source exactly_once=true Three restore cycles passed Three restore cycles passed; final 96 rows matched
Three-table JDBC without XA, source exactly_once=false Three restore cycles passed Three restore cycles passed; final 96 rows matched
Three-table JDBC XA, parallelism 2 and multi_table_sink_replica=2 Original restore failure reproduced The old checkpoint transactions were handled correctly, but a subsequent normal commit failed due to the separate cleanup issue below; reproduced again in a fresh run
Three-table JDBC XA, parallelism 1 and replica 1 — The same subsequent-commit failure reproduced
Three-table JDBC XA with source exactly_once=false Original restore failure reproduced The same subsequent-commit failure reproduced

For JDBC with is_exactly_once=false, no JDBC aggregated committer is created, so this change does not alter that JDBC recovery path. Turning off source exactly-once alone does not remove the sink's XA recovery requirements.

Real Iceberg recovery tests

I also exercised the production IcebergAggregatedCommitter through the multi-table wrapper using two HadoopCatalog tables and actual Parquet files.

Scenario Result
Restore an already-committed checkpoint Dev appended the same files again: each table grew from 2 to 4 rows. With the PR, three repeated restores preserved row counts and snapshot IDs
Restore pending files Files committed once
One table already committed, another still pending Both tables recovered without duplicate appends
Checkpoint ID zero / existing-file fallback Passed
Empty restore state Passed
Serialize commit state, create fresh committers, and restore against the existing catalog Passed; snapshots unchanged

Nine Iceberg checks passed. This was a separate local connector recovery test, rather than a run of the existing Iceberg savepoint IT.

Separate, pre-existing JDBC XA cleanup issue

The multi-table XA job failures above are important to distinguish from this PR's forwarding fix.

After restoration, a table writer can prepare a valid new transaction before another table writer first opens. The latter calls recoverAndRollback(). Its ownership check matches the job ID and subtask index, without distinguishing the other table's branch, so it can roll back that valid peer transaction. The next normal checkpoint commit then fails with XAER_NOTA.

I reproduced this independently with real prepared MySQL XA branches on both dev and the PR:

  • Two table branches were prepared.
  • Production recovery cleanup reduced the prepared count from two to one.
  • Committing the other table's branch returned XAER_NOTA.

In the complete PR job, the logs first showed the restored checkpoint's already-resolved XIDs being skipped correctly. The later failure involved a new transaction and occurred through normal notifyCheckpointComplete → commit(), rather than the restored checkpoint's commit path.

As a diagnostic control only, narrowing cleanup ownership in an isolated local copy preserved both prepared branches and allowed the same three-table job to complete all three restores and subsequent DML, ending with 96 matching rows and 204 audit records. This experimental change is not part of the PR, is not presented as a complete production fix, and its successful run is not counted as a successful run of the unmodified PR.

This existing JDBC issue should be tracked separately. It does not invalidate the wrapper forwarding fix, but the results should not be described as closing every multi-table XA recovery scenario.

An additional abrupt-Master-termination probe in the embedded setup timed out and remains inconclusive; it is not counted among the passing tests or attributed to this PR.

I support the focused forwarding change. The local tests confirm the intended dispatch, unchanged default behavior, and the JDBC/Iceberg recovery improvement.

@nzw921rx
nzw921rx merged commit ebb2cc3 into apache:dev Oct 28, 2026
3 of 4 checks passed
@SEZ9

SEZ9 commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @nzw921rx for the thorough local verification on c3437e23a79733fe996fdcb14d647ce596488178 with dev at 403efeee0b3806c77e55c38368abdd41fbf828bd. Your call-chain summary matches my reading: normal commits still go through commit(), restores now go through each table's restoreCommit(), and committers without an override fall back to the interface default.

A few items before this merges, mapped to the earlier review points:

Tests (F5 / F6) – The eight supplemental wrapper tests you describe (per-table routing, unequal non-empty retry lists with table identifiers preserved, default restoreCommit() → commit() delegation, empty restored state) are exactly the coverage I asked for. Since they were only run locally, please add them to MultiTableSinkAggregatedCommitterTest in this PR so the restore path stays protected going forward.

Fail-fast on restore (F1) – "Exceptions remaining visible, with the existing fail-fast behavior" confirms the current behaviour but doesn't resolve the concern: when one table throws, the remaining tables are never restored and the propagated exception carries no table identifier. I'm fine with either (a) wrapping the exception with the table identifier in this PR, or (b) explicitly deferring it to a follow-up. Please say which.

Iceberg (F4) – 131 Iceberg unit tests passing is good, but the real recovery runs described are MySQL-CDC → JDBC only. This PR makes IcebergAggregatedCommitter.restoreCommit reachable under Zeta for the first time, so please either run the existing Iceberg savepoint IT against this head and report the result, or note it as explicitly unvalidated.

Docs (F2 / F3) – Not mentioned yet: the stale restoreCommit signature in the architecture doc and a release/upgrade note for the JDBC XA / Iceberg restore behaviour change (including correcting the existing JDBC XA entry in incompatible-changes.md) are still open.

Style (F7 / F8) – Minor: move the // explanation above the override annotation into Javadoc and use List<?> instead of raw List on the changed line.

CI – Run 40507160077 / job 122200579062 was cancelled on timeout rather than failing, so I'd prefer a re-trigger to get a completed run on record rather than bypassing, given the API module is in the blast radius.

Also, the negative-controls table in your comment appears cut off after the header row — could you repost the dev-control vs. PR results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Zeta][Connector-V2] JDBC exactly-once restore fails with XAER_NOTA: MultiTableSinkAggregatedCommitter never calls the sink's restoreCommit

4 participants