Skip to content

MDEV-39681 delayed BF aborting with multi master load#5319

Open
sjaakola wants to merge 1 commit into
10.11from
10.11-MDEV-39681
Open

MDEV-39681 delayed BF aborting with multi master load#5319
sjaakola wants to merge 1 commit into
10.11from
10.11-MDEV-39681

Conversation

@sjaakola

@sjaakola sjaakola commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reason for the hanging, and occasional crashes turned out to be orphaned innodb lock wait request of a BF aborted local transaction, which had arrived in commit stage.

Reason is that wsrep BF-abort marks a transaction a deadlock victim out-of-band, so (unlike native deadlock resolution) the victim can still own a live LOCK_WAIT request; if that orphaned waiter survives into commit/rollback, another transaction granting it calls lock_wait_end() cross-thread and corrupts the victim's state — surfacing as the lock_wait_end, que_thr_step, and rollback_finish assertions.

This commit has fixes for claering lock wait status of BF aborted transactions.

Commit has also a new mtr test: galera.galera_bf_abort_orphan_lock to work as regression test for the fix.

Reason for the hanging, and occasional crashes turned out
to be orphaned innodb lock wait request of a BF aborted
local transaction, which had arrived in commit stage.

Reason is that wsrep BF-abort marks a transaction a deadlock
victim out-of-band, so (unlike native deadlock resolution)
the victim can still own a live LOCK_WAIT request;
if that orphaned waiter survives into commit/rollback,
another transaction granting it calls lock_wait_end() cross-thread
and corrupts the victim's state — surfacing as the lock_wait_end,
que_thr_step, and rollback_finish assertions.

This commit has fixes for claering lock wait status of BF aborted
transactions.

Commit has also a new mtr test: galera.galera_bf_abort_orphan_lock
to work as regression test for the fix.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where a local transaction BF-aborted (wsrep victim) could park an orphaned lock wait request, leading to assertion failures during rollback. The fix ensures that transactions already chosen as victims return DB_DEADLOCK immediately instead of enqueuing new waiting locks, and cancels pending waits for wsrep BF-abort victims in lock_trx_handle_wait. A new test case has been added to verify the fix. The review feedback highlights some minor typos and spacing issues in the comments, a style violation regarding spacing around an assignment operator, and the use of the deprecated tx_isolation system variable in the test files.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1502 to +1504
/* If this transaction has already been chosen as a victim — it must not
enqueue a new waiting lock request.
Return DB_DEADLOCK so that the caller rolls back instead of waiting. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the comment: rolls back has an extra space. It should be rolls back.

	/* If this transaction has already been chosen as a victim — it must not
	enqueue a new waiting lock request.
	Return DB_DEADLOCK so that the caller rolls back instead of waiting. */

Comment on lines +6723 to +6729
/* A wsrep BF-abort marks the victim out-of-band: unlike native deadlock
resolution it does not cancel the victim's waiting lock atomically with
setting the flag, so the victim can reach this point still owning a live
LOCK_WAIT request (with trx->lock.wait_thr set).
So for BF-abort victm, we cancel the pending wait
here, which also clears trx->lock.wait_thr. But, this must not be done for
the native deadlock case, which cancels lock in Deadlock::report() */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a few typos and spacing issues in this comment:

  • victm should be victim.
  • There are double spaces after commas/periods (e.g., victm, we and thr. But).
  • There are double spaces before the closing comment marker */.
  /* A wsrep BF-abort marks the victim out-of-band: unlike native deadlock
  resolution it does not cancel the victim's waiting lock atomically with
  setting the flag, so the victim can reach this point still owning a live
  LOCK_WAIT request (with trx->lock.wait_thr set). 
  So for BF-abort victim, we cancel the pending wait
  here, which also clears trx->lock.wait_thr. But, this must not be done for
  the native deadlock case, which cancels lock in Deadlock::report() */

if (trx->lock.wait_lock)
{
mysql_mutex_lock(&lock_sys.wait_mutex);
if (lock_t *wait_lock= trx->lock.wait_lock)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Following the project's coding standards, there should be spaces around the assignment operator =.

      if (lock_t *wait_lock = trx->lock.wait_lock)
References
  1. Follow the project's specific coding standards (e.g., CODING_STANDARDS.md) for code formatting and spacing, such as spacing around assignment operators, rather than generic style guides like the Google C++ Style Guide. (link)


# Victim: holds a granted lock on t_a (makes it a BF target), then locks t_b
--connect node_1_victim, 127.0.0.1, root, , test, $NODE_MYPORT_1
SET SESSION tx_isolation = 'READ-COMMITTED';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The system variable tx_isolation is deprecated. It is recommended to use transaction_isolation instead. Also, there are extra spaces before the = operator.

SET SESSION transaction_isolation = 'READ-COMMITTED';

id c
1 0
connect node_1_victim, 127.0.0.1, root, , test, $NODE_MYPORT_1;
SET SESSION tx_isolation = 'READ-COMMITTED';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The system variable tx_isolation is deprecated. It is recommended to use transaction_isolation instead. Also, there are extra spaces before the = operator.

SET SESSION transaction_isolation = 'READ-COMMITTED';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant