[MDEV-32672] Don't hold LOCK_thd_data over commit_ordered Created: 2023-11-03  Updated: 2023-11-03  Resolved: 2023-11-03

Status: Closed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.4.31
Fix Version/s: 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2

Type: Bug Priority: Major
Reporter: Kristian Nielsen Assignee: Kristian Nielsen
Resolution: Fixed Votes: 0
Labels: None


 Description   

Revert the replication part of this commit:

commit 6b685ea7b0776430d45b095cb4be3ef0739a3c04
Author: Sergei Golubchik <serg@mariadb.org>
Date:   Wed Sep 28 18:55:15 2022 +0200
 
    correctness assert
 
    thd_get_ha_data() can be used without a lock, but only from the
    current thd thread, when calling from anoher thread it *must*
    be protected by thd->LOCK_thd_data
 
    * fix group commit code to take thd->LOCK_thd_data

The group commit code must not take thd->LOCK_thd_data over run_commit_ordered().
The thd is at this point temporarily transferred to the current thread. Taking LOCK_thd_data incurs a performance penalty for every (binlog) commit. Worse, if any storage engine code implementing the commit_ordered handlerton call would try to take the mutex (to modify THD data), the server would deadlock on a recursive mutex take.

Instead, set_current_thd() for the duration of the commit_ordered call. If any code should access the current_thd, the correct value is the THD of the transaction being committed here, not the THD of the group commit leader.

Mailing list thread: https://lists.mariadb.org/hyperkitty/list/developers@lists.mariadb.org/thread/TPJ5RI2F2QFX5T6QWZZIETVC3RNOYPVC/



 Comments   
Comment by Kristian Nielsen [ 2023-11-03 ]

Pushed to 10.5.

Generated at Thu Feb 08 10:33:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.