You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go's map do not guarantee ordering (the Go team even intentionally build randomisation into it to dissuade people from depending on its order), so switch to iterating ordered pk slice instead.
josephwoodward
changed the title
mysql_cdc: ensure snapshot column order is consistent for composite primary keys
mysql_cdc: ensure snapshot primary key order is consistent for composite primary keys
Apr 15, 2026
Review
Clean bug fix: querySnapshotTable was iterating over a map[string]any (*lastSeenPkVal) directly, which yields non-deterministic key order in Go. For composite primary keys, this caused the values passed to the WHERE (col1, col2) > (?, ?) clause to potentially be in the wrong order relative to the column names from pk, resulting in incorrect snapshot pagination. The fix iterates over the ordered pk slice and looks up each value by name, ensuring consistent column-value alignment. Covered by existing integration test TestIntegrationMySQLCDCWithCompositePrimaryKeys.
Review
Single-file bug fix in internal/impl/mysql/snapshot.go that switches snapshot pagination from iterating over a map (non-deterministic order in Go) to iterating over the pk slice, ensuring primary key column values are always in the correct order when constructing the paginated query. The missing-key error path is handled properly.
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
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.
Go's map do not guarantee ordering (the Go team even intentionally build randomisation into it to dissuade people from depending on its order), so switch to iterating ordered pk slice instead.
Closes: #4256