OpenTenBase / OpenTenBase/TXSQL

BUG#34930969: Previous_gtids miss gtid when binlog_order_commits off

Open
#94 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
337
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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

https://github.com/xyw0537/TXSQL/commit/ae7de225c2a

Branch: bugfix/previous_gtids_miss_gtid_binlog_order_commits_off

Upstream Reference

https://github.com/mysql/mysql-server/commit/a3faa6f8799e6c7c610245d2899386131731fb41

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating MYSQL_BIN_LOG::finish_commit and inspect the ordering of dec_prep_xids and gtid_state->update_on_commit. Review the after_dec_prep_xids DEBUG_SYNC point and the MTR test case rpl_previous_gtids. Done means the test verifies that Previous_gtids includes all committed GTIDs when binlog_order_commits is off.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, mysql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.