Skip to content

feat: MariaDB GTID support#1731

Open
conf wants to merge 1 commit into
github:masterfrom
conf:mariadb-gtid-support
Open

feat: MariaDB GTID support#1731
conf wants to merge 1 commit into
github:masterfrom
conf:mariadb-gtid-support

Conversation

@conf

@conf conf commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

A Pull Request should be associated with an Issue.

Related issue: none yet — happy to open one to discuss direction if preferred.

Description

This PR adds MariaDB GTID support to gh-ost. gh-ost hard-coded the go-mysql binlog syncer to MySQLFlavor and parsed every GTID set as MySQL, so --gtid could not be used against MariaDB. go-mysql already speaks the MariaDB GTID dialect; this wires it up.

  • Detect the server flavor from the version string (IsMariaDB / FlavorFor) and set it on the BinlogSyncerConfig.
  • Make GTIDBinlogCoordinates hold the flavor-agnostic gomysql.GTIDSet interface; parse via ParseGTIDSet(flavor, ...).
  • Handle MariadbGTIDEvent alongside GTIDEvent in the streamer, and read the committed GTID set from XIDEvent.GSet without a MySQL-only cast.
  • Read MariaDB GTID positions from @@global.gtid_binlog_pos, Gtid_IO_Pos and @@global.gtid_slave_pos (MariaDB exposes no Executed_Gtid_Set column, nor gtid_mode / enforce_gtid_consistency).
  • Skip the gtid_mode / enforce_gtid_consistency validation on MariaDB, where GTIDs are always recorded when binary logging is enabled.

localtests

  • Run gtid_mode=ON cases on MariaDB (normalize its current_gtid_mode to ON) and trim the GTID diagnostics that don't exist on MariaDB.
  • Enable gtid_strict_mode on the MariaDB test servers. Because --test-on-replica makes gh-ost write locally on the replica, give the replica its own GTID domain so its writes never collide with the primary's domain-0 stream under strict mode.
  • Add a gtid-resume case: interrupt a --gtid migration mid-copy via the interactive panic command, then --resume, exercising the GTID checkpoint round-trip (WriteCheckpoint persists the GTID set, ReadLastCheckpoint parses it back via NewGTIDBinlogCoordinates(flavor, …)).

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

gh-ost hard-coded the go-mysql binlog syncer to MySQLFlavor and parsed
every GTID set as MySQL, so --gtid could not be used against MariaDB.
go-mysql already speaks the MariaDB GTID dialect; this wires it up.

- Detect server flavor from the version string (IsMariaDB / FlavorFor)
  and set it on the BinlogSyncerConfig.
- Make GTIDBinlogCoordinates hold the flavor-agnostic gomysql.GTIDSet
  interface; parse via ParseGTIDSet(flavor, ...).
- Handle MariadbGTIDEvent alongside GTIDEvent in the streamer, and read
  the committed GTID set from XIDEvent.GSet without a MySQL-only cast.
- Read MariaDB GTID positions from @@global.gtid_binlog_pos,
  Gtid_IO_Pos and @@global.gtid_slave_pos (MariaDB has no
  Executed_Gtid_Set column nor gtid_mode / enforce_gtid_consistency).
- Skip the gtid_mode / enforce_gtid_consistency validation on MariaDB,
  where GTIDs are always recorded when binary logging is enabled.

localtests:
- Detect the server version once and reuse it; run gtid_mode=ON tests on
  MariaDB (normalize its current_gtid_mode to ON) and trim the GTID
  diagnostics that don't exist on MariaDB.
- Enable gtid_strict_mode on the MariaDB test servers. Because
  --test-on-replica makes gh-ost write locally on the replica, give the
  replica its own GTID domain so its writes never collide with the
  primary's domain-0 stream under strict mode.
- Add the gtid-resume case: interrupt a --gtid migration mid-copy via the
  interactive 'panic' command, then --resume, exercising the GTID
  checkpoint round-trip (WriteCheckpoint persists the GTID set,
  ReadLastCheckpoint parses it back via NewGTIDBinlogCoordinates(flavor)).
  Passes across the MySQL, MariaDB and Percona CI matrix.

Verified: full localtests suite passes on MySQL 5.7/8.0/8.4 and on the
MariaDB matrix (10.5, 10.6, 10.11, 11.4, 11.8) with gtid_strict_mode on.
@conf conf force-pushed the mariadb-gtid-support branch from a6b31c8 to 167d444 Compare June 28, 2026 11:19
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