Skip to content

GTID 3/5: Binlog streaming start/stop (behind mode flag)#447

Open
driv3r wants to merge 4 commits into
gtid-stage2-coordinate-modefrom
gtid-stage3-streamer
Open

GTID 3/5: Binlog streaming start/stop (behind mode flag)#447
driv3r wants to merge 4 commits into
gtid-stage2-coordinate-modefrom
gtid-stage3-streamer

Conversation

@driv3r

@driv3r driv3r commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Stacked PR 3 of 5 — GTID support

Base: #446. Review/merge in stack order.

What this PR does

Wires the GTID coordinate mode into BinlogStreamer so a fresh run can stream from and stop at a GTID set, while file/position stays the default and unchanged.

  • BinlogStreamer gains BinlogCoordinateMode plus GTID tracking of the streamed, resumable, and stop GTID sets.
  • ConnectBinlogStreamerToMysqlWithCoordinate / ...FromCoordinate dispatch to StartSync (file/pos) or StartSyncGTID (gtid), with coordinate-type validation.
  • Tracks committed GTID via XIDEvent.GSet; records the pre-transaction set as the resumable point at GTIDEvent (clone to avoid aliasing go-mysql's mutable set).
  • Loop stop condition replaced with shouldContinueStreaming (position compare for file/pos, executed-set containment for GTID). FlushAndStop records the GTID stop set.
  • Ferry passes the mode to its streamers and uses coordinate-based connect/state updates. GTID resume-from-state is explicitly rejected until GTID state persistence lands (PR 4).
  • Internal unit tests for mode dispatch, stop logic, and validation.

File/position behavior is unchanged; GTID streaming works for fresh runs.

driv3r added 4 commits July 22, 2026 20:42
Wire the GTID coordinate mode into BinlogStreamer so a fresh run can
stream from and stop at a GTID set, while file/position stays the
default and unchanged.

- BinlogStreamer gains BinlogCoordinateMode plus GTID tracking of the
  streamed, resumable, and stop GTID sets.
- Add ConnectBinlogStreamerToMysqlWithCoordinate and
  ...FromCoordinate that dispatch to StartSync (file/pos) or
  StartSyncGTID (gtid), with coordinate-type validation.
- Track committed GTID via XIDEvent.GSet and record the pre-transaction
  set as the resumable point at GTIDEvent; clone to avoid aliasing
  go-mysql's mutable set.
- Replace the Run loop stop condition with shouldContinueStreaming,
  which uses position compare for file/pos and executed-set containment
  for GTID. FlushAndStop records the GTID stop set.
- Ferry passes the mode to its streamers and uses coordinate-based
  connect/state updates. GTID resume-from-state is explicitly rejected
  until GTID state persistence lands.
- Add internal unit tests for mode dispatch, stop logic, and validation.

File/position behavior is unchanged; GTID streaming works for fresh
runs. GTID resume and verifier/progress/replica-catchup wiring follow in
later stages.
shouldContinueStreaming no longer branches on coordinate type: it asks
GetLastStreamedBinlogCoordinate().HasReached(GetStopBinlogCoordinate()),
delegating the file/position-vs-GTID mechanics to BinlogCoordinate. Add
GetStopBinlogCoordinate so both the streamed and stop roles are exposed
as coordinates. A zero stop coordinate means "no target recorded yet",
matching the previous guard.
"From" read too much like the "With" (start-from-current) variant.
"Since" makes it clear the streamer starts since the given coordinate.
- shouldContinueStreaming no longer treats an empty stop coordinate as
  "unset". FlushAndStop always records the stop target before setting
  stopRequested, so an empty executed GTID set on a fresh source is a
  valid target that is immediately reached, rather than hanging cutover.
- Advance the streamed GTID set on DDL/admin QueryEvents (which commit
  without an XIDEvent), skipping transaction-control statements (BEGIN).
  Previously a cutover whose stop target ended in a DDL could hang.
- Validate @@GLOBAL.gtid_mode=ON for the source (and target when target
  verification is enabled) during Ferry.Initialize when in GTID mode, so
  misconfiguration fails fast instead of late during streaming.
- Add unit tests for the empty stop target, QueryEvent advancement, and
  transaction-control detection.
@driv3r
driv3r force-pushed the gtid-stage3-streamer branch from 2132529 to e3d40fb Compare July 22, 2026 19:00
@driv3r
driv3r requested review from a team, milanatshopify and pawandubey July 22, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant