Problem
When binlog_order_commits is turned off, binlog rotate will wait for m_prep_xids to decrease to zero. However, m_prep_xids was decreased before updating the thread GTID to gtid_executed in MYSQL_BIN_LOG::finish_commit, causing GTIDs to be missed in the next binlog file Previous_gtids event.
Fix
The core fix moves dec_prep_xids to be called after gtid_state->update_on_commit in MYSQL_BIN_LOG::finish_commit. This ensures that when binlog rotate waits for m_prep_xids to reach zero, all GTIDs have already been registered in gtid_executed.
Additionally:
- Added
DEBUG_SYNC point after_dec_prep_xids to enable deterministic testing
- Added MTR test case
rpl_previous_gtids to verify the fix
Commit
xyw0537@ae7de225c2a
Branch: bugfix/previous_gtids_miss_gtid_binlog_order_commits_off
Upstream Reference
mysql/mysql-server@a3faa6f
Problem
When
binlog_order_commitsis turned off,binlog rotatewill wait form_prep_xidsto decrease to zero. However,m_prep_xidswas decreased before updating the thread GTID togtid_executedinMYSQL_BIN_LOG::finish_commit, causing GTIDs to be missed in the next binlog file Previous_gtids event.Fix
The core fix moves
dec_prep_xidsto be called aftergtid_state->update_on_commitinMYSQL_BIN_LOG::finish_commit. This ensures that when binlog rotate waits form_prep_xidsto reach zero, all GTIDs have already been registered ingtid_executed.Additionally:
DEBUG_SYNCpointafter_dec_prep_xidsto enable deterministic testingrpl_previous_gtidsto verify the fixCommit
xyw0537@ae7de225c2a
Branch:
bugfix/previous_gtids_miss_gtid_binlog_order_commits_offUpstream Reference
mysql/mysql-server@a3faa6f