Fix lexographical comparison of binlog filenames#1604
Merged
meiji163 merged 2 commits intogithub:masterfrom Nov 6, 2025
Merged
Conversation
… correctly order files like binlog.999999 < binlog.1000000. Would cause the stream to ignore all incoming events and render the gh-ost process stuck: https://github.com/github/gh-ost/blob/48b34bcbfde730b2548d598dee98e9c1f0d2fcce/go/binlog/gomysql_reader.go#L85-L88 Possibly remediated by 005043d too, which drops the SmallerThanOrEqual check from GoMySqlReader.handleRowsEvent
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the SmallerThan method in FileBinlogCoordinates to use numeric file number comparison instead of lexicographic string comparison, fixing a bug where binlog file comparisons would fail when file numbers transitioned from 6 digits to 7 digits (e.g., "mysql-bin.999999" vs "mysql-bin.1000000").
- Replaced string comparison with
FileNumberDistancemethod for accurate numeric comparison - Removed unused
FileSmallerThanmethod - Added test coverage for edge cases including zero-padded transitions and same-file position comparisons
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| go/mysql/binlog_file.go | Refactored SmallerThan to use numeric file comparison via FileNumberDistance; removed unused FileSmallerThan method |
| go/mysql/binlog_file_test.go | Added tests for binlog file number transitions and same-file position comparisons |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
meiji163
approved these changes
Nov 6, 2025
Contributor
|
Thanks for submitting this fix! |
This was referenced Nov 7, 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.
Closes #1603, please see the issue contents for context.