Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds GTID (Global Transaction Identifier) support to gh-ost for streaming the binary log, which is necessary for implementing migration checkpoints and resumability. The main changes introduce a new --gtid flag that requires gtid_mode=ON and enforce_gtid_consistency=ON.
- Replaced file-based binlog coordinates with a
BinlogCoordinatesinterface supporting both file and GTID coordinate types - Updated reconnection logic to use last complete transaction coordinates for better reliability
- Added GTID validation and configuration checks
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| go/mysql/binlog.go | Converted from struct to interface for coordinate abstraction |
| go/mysql/binlog_file.go | New file implementing file-based binlog coordinates |
| go/mysql/binlog_gtid.go | New file implementing GTID-based binlog coordinates |
| go/binlog/gomysql_reader.go | Updated to handle both coordinate types and track complete transactions |
| go/logic/streamer.go | Enhanced reconnection logic using last transaction coordinates |
| go/logic/inspect.go | Added GTID configuration validation |
| go/cmd/gh-ost/main.go | Added --gtid command line flag |
| localtests/test.sh | Added GTID test support and configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ericyan
approved these changes
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is a continuation of @timvaillancourt's PR #950 to add GTID support for streaming the binlog. Enable it with the
--gtidflag. It requiresgtid_mode=ONandenforce_gtid_consistency=ON, which is available in all MySQL versions supported by gh-ost.Replacing file-based coordinates with GTID set coordinates is necessary for implementing migrations checkpoints and resumability in the future.
Details
mysql.BinlogCoordinatesinterface, implemented byFileBinogCoordinatesandGTIDBinlogCoordinates. GTID set operations are provided by go-mysql'sreplicationpackage.GoMySQLReader.currentCoordinatestracks the currently streaming transaction, whileGoMySQLReader.LastTrxCoordstracks the last read transaction (similar toRetrieved_Gtid_Set).EventsStreamer.StreamEventsreconnection logic to use theLastTrxCoords. Surprisingly, the retry logic is currently unused because the go-mysqlreplication.BinlogSyncerhas its own retry mechanism. My testing showed no problems with using the new reconnection logic, but I will not enable it now to keep this PR low risk.Testing
All localtests pass with gtid mode (
./script/docker-gh-ost-replica-tests run -g). Additionally, internal replica tests on production tables have been running for a day and revealed no data integrity issues.script/cibuildreturns with no formatting errors, build errors or unit test errors.