You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "ricky2129 (via GitHub)" <gi...@apache.org> on 2026/09/29 16:05:32 UTC
[PR] [Bug][Connector-V2][CDC-MySQL] Do not replay a GTID lineage the checkpoint does not track [seatunnel]
ricky2129 opened a new pull request, #12555:
URL: https://github.com/apache/seatunnel/pull/12555
### Purpose of this pull request
Closes #12554.
On a MySQL source that carries a GTID lineage inherited from a previous master, a restored
MySQL-CDC job re-reads everything the server still retains for that lineage. In our case four jobs
walked back about 100 binlog files and took roughly two and a half days to catch up.
`MySqlStreamingChangeEventSource#filterGtidSet` drops any lineage the restored GTID set does not
mention, and only `purgedServerGtid` brings it back, which reaches no further than `gtid_purged`.
Everything the server retains past the purge point then looks unconsumed and is sent again. A job
started with `startup.mode = specific` never records a lineage that went quiet before its start
position, so it is exposed from its first checkpoint.
The `Previous_gtids` event of the binlog file being resumed from is the set executed before that
file, which is the one thing that separates a dormant lineage from one that has just become active
after a failover. This reads it and merges in only the lineages the checkpoint does not track, so a
position already recorded is never overridden.
One detail worth flagging for review: `GtidUtils.mergeGtidSetInto` keeps the entry already held for
a UUID rather than replacing it, so `Previous_gtids` has to be merged **before** the purged set.
The other order silently discards it, since the purged set only reaches the purge point.
If `SHOW BINLOG EVENTS` fails, for example when the account has no `REPLICATION SLAVE` privilege,
the warning is logged and the merge behaves exactly as it does today rather than blocking startup.
`GtidUtilsTest` covers the three cases that have to be told apart, and asserts the old result as
well as the new one so the difference is visible:
| case | claimed before | claimed with this change |
|---|---|---|
| lineage missing from the checkpoint, executed earlier | `B:1-900` (purge point) | `B:1-1000` |
| checkpoint tracks every lineage | unchanged | unchanged |
| lineage active after the resume position | not claimed | not claimed |
The same merge exists in upstream Debezium and is reported there as debezium/dbz#2731, with a fix
in debezium/debezium#8135. SeaTunnel needs its own change because of the merge-order difference
described above.
### Does this PR introduce _any_ user-facing change?
No new configuration. A job restored on a server carrying a lineage its checkpoint does not track
no longer re-reads that lineage from the oldest retained binlog. Behaviour is unchanged when the
checkpoint already tracks every lineage on the server.
### How was this patch tested?
`GtidUtilsTest`, four new cases alongside the two existing ones, all passing:
```
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
```
`Previous_gtids` parsing was checked over JDBC against MySQL 8.4.5. The value carries a newline
after the comma when more than one lineage is present, and is empty for the oldest retained file.
### Check list
* [X] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [X] If necessary, please update the documentation to describe the new feature.
https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md
* [X] If you are contributing the connector code, please check that the following files are updated:
1. Update change log that in connector document. For more details you can refer to
[connector-v2](https://github.com/apache/seatunnel/tree/dev/docs/en/connector-v2)
2. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
and add new connector information in it
3. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
* [X] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Bug][Connector-V2][CDC-MySQL] Do not replay a GTID lineage the checkpoint does not track [seatunnel]
Posted by "ricky2129 (via GitHub)" <gi...@apache.org>.
ricky2129 commented on PR #12555:
URL: https://github.com/apache/seatunnel/pull/12555#issuecomment-5908679909
Flagging a problem with this before anyone spends review time on it.
I raised the same change against Debezium (debezium/debezium#8135) and a maintainer there pointed out a data-loss path I had missed. In GTID mode the position comes from `client.setGtidSet(...)`, and the binlog filename is used only when there is no GTID set at all. That is what makes GTID mode safe when the source moves. This change reads `Previous_gtids` for the filename recorded in the checkpoint, but on whichever server the job happens to be connected to. If the source has been repointed to a promoted server, that server can hold a file of the same name whose `Previous_gtids` contains its own lineage. That lineage is not in the checkpoint, so `untrackedGtids` keeps it and those transactions are marked consumed without ever being read.
As written it trades re-delivery for silent loss in the failover case, which is the worse of the two. Please don't merge it in this shape.
The bug in #12554 stands on its own. The merge does claim an untracked lineage only as far as `gtid_purged`, and that is still unfixed on `dev`. It is the remedy here that is wrong.
Worth noting what does not rescue it: inferring same-server by checking whether the checkpoint tracks `@@global.server_uuid`. server_uuid appears in `gtid_executed` only for transactions the server originated, so on a read replica the server's own lineage is absent from the set entirely and the check fails closed on exactly the case it is meant to permit.
What it needs is for the checkpoint to record the source server's identity explicitly, so the filename is used only when the source has not changed. Same uuid means the file and position are genuinely ours and `Previous_gtids` answers it precisely; a different uuid, or an older checkpoint with nothing recorded, means we cannot know and the merge should stay as it is today. That only helps checkpoints written after the change, which is the real cost, but it never trades re-delivery for loss.
Separately, the size of the problem is already computable inside `filterGtidSet` with no extra query and no behaviour change: for a lineage the server has and the checkpoint does not, `gtid_executed` minus `gtid_purged` is the number of transactions about to be re-delivered. Ours was around fifteen million with nothing in the log to say so, and that was the worse half of the incident.
I will rework this once the Debezium discussion settles on a shape, since both projects carry the same merge. Happy to close this and open a fresh one with the revised approach if that is cleaner for review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Bug][Connector-V2][CDC-MySQL] Do not replay a GTID lineage the checkpoint does not track [seatunnel]
Posted by "ricky2129 (via GitHub)" <gi...@apache.org>.
ricky2129 commented on PR #12555:
URL: https://github.com/apache/seatunnel/pull/12555#issuecomment-5918137147
@davidzollo ^
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Bug][Connector-V2][CDC-MySQL] Do not replay a GTID lineage the checkpoint does not track [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on PR #12555:
URL: https://github.com/apache/seatunnel/pull/12555#issuecomment-5988323726
@ricky2129 thanks for the PR — the problem it targets (re-reading retained transactions of a lineage the checkpoint never tracked) is real and worth fixing. Here is where I'd like to land on the open points:
**1. Previous_gtids looked up by binlog filename (HIGH, blocking).** In GTID mode the GTID set is the server-stable identifier; the filename only means something on the server that wrote it. After a failover to a promoted/different server that has a same-named file, `previousGtidSet` returns that server's own lineages, `untrackedGtids` keeps them (they are not in the checkpoint), and they end up in the set passed to `client.setGtidSet` — so transactions the job never consumed are marked done and skipped. I'd like the claimed lineages to be derived from something that is robust to a host change (or the merge to be gated so it cannot run against a server other than the one the checkpoint came from). Could you describe the approach you intend to take before pushing code?
**2. `SHOW BINLOG EVENTS` query (MEDIUM).** Please validate the restored filename (e.g. against the expected binlog-name shape) rather than interpolating it directly, and avoid the hard-coded `LIMIT 3` — read until the `Previous_gtids` event is found or bail out explicitly.
**3. Extra round-trip and WARN on every restart (LOW).** Please only issue the query when there is actually an untracked lineage to resolve, and downgrade/shorten the log for accounts lacking the privilege so a normal restart does not emit a full stack trace.
**4. Tests (MEDIUM/LOW).** `GtidUtilsTest` currently re-implements the merge in a private `merge` helper, so a divergence from `filterGtidSet` in `MySqlStreamingChangeEventSource` would go unnoticed. Please exercise `filterGtidSet` directly, cover `previousGtidSet` / the `SHOW BINLOG EVENTS` parsing path, and extend the existing MySQL-CDC E2E suite with the restore scenario this PR changes (untracked lineage present on the server), plus a case for the host-change situation from point 1 once you have a fix.
**5. Docs (LOW).** Since restore semantics for GTID-mode jobs change on upgrade (extra server query, different starting GTID set), please add a note to the MySQL-CDC docs and `incompatible-changes.md`.
Happy to review again once point 1 has a concrete design and the tests are in place.
<!-- streview-comment:1532 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org