[MDEV-5636] Deadlock in RESET MASTER Created: 2014-02-09  Updated: 2014-02-10  Resolved: 2014-02-10

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.7
Fix Version/s: 10.0.9

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


 Description   

This failure is a race that is quite rare, but I can usually repeat it with
eg.

./mtr rpl.rpl_gtid_basic --repeat=100 --parallel=6

The problem is a deadlock between MYSQL_BIN_LOG::reset_logs() and
MYSQL_BIN_LOG::mark_xid_done(). The former takes LOCK_log and waits for the
latter to complete. But the latter also tries to take LOCK_log; this can lead
to a deadlock.

There is already code that tries to deal with this, with the flag
reset_master_pending. However, there was still a small opportunity for
deadlock, when an previous mark_xid_done() is still running when reset_logs()
is called and is at the precise point where it first releases LOCK_xid_list
and then re-aquires both LOCK_log and LOCK_xid_list.

Proposed solution: set reset_master_pending in reset_logs() before taking
LOCK_log. And also count how many invocations of LOCK_xid_list are in the
progress of releasing and re-aquiring locks, and in reset_logs() wait for that
number to drop to zero after setting reset_master_pending and before taking
LOCK_log.



 Comments   
Comment by Kristian Nielsen [ 2014-02-09 ]

Patch committed and pushed to 10.0-knielsen for test.

Comment by Kristian Nielsen [ 2014-02-10 ]

Pushed to 10.0-base and 10.0

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