forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing missed notification in wait_for_all_committing_trxs_to_finish()
Summary: There were two problems with the existing code that caused missed notification such that `wait_for_all_committing_trxs_to_finish()` waited forever: 1. In group commit the follower threads were incrementing committing trxs without holding LOCK_log which meant that the counter could increment after going down to 0 and since the counter doesn't use mutex (it's atomic) there can be a race such that the predicate check while waiting fails and we never notify after so we're stuck. Another problem with this was that the counter can go to 0 if only the leader thread decrements it before the followers have the chance to increment it. This will cause us to wake up before all trxs are actually finished. 2. Since we don't hold a mutex while inc and dec the counter there can be a race such that the waiting thread fails the predicate on a non-zero counter, then before we go into waiting, the counter is dec to 0 and we notify. But since the notification happened before we went into waiting we miss it completely and wait forever. To fix facebook#1 we make sure that we increment the counter only while holding LOCK_log. To fix facebook#2 we take a mutex before notifying when the counter goes to 0, this way the notification will be either entirely before or after the wait. Out of paranoia also added a gvar to skip waiting altogether and converted the wait() to a wait_for(). Test Plan: Ran a mysqlslap with high concurrency on both primary and replica and created snapshots on loop. Also exiting mtr for functional testing. Reviewers: yoshinori, yichenshen Reviewed By: yichenshen Differential Revision: https://phabricator.intern.facebook.com/D59882151
- Loading branch information
1 parent
1d51c17
commit d60dc70
Showing
8 changed files
with
75 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
mysql-test/suite/sys_vars/r/include_applied_opid_in_snapshot_info_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Default value is true | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
@@global.include_applied_opid_in_snapshot_info | ||
1 | ||
SELECT @@session.include_applied_opid_in_snapshot_info; | ||
ERROR HY000: Variable 'include_applied_opid_in_snapshot_info' is a GLOBAL variable | ||
Expected error 'Variable is a GLOBAL variable' | ||
SET @@global.include_applied_opid_in_snapshot_info = true; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
@@global.include_applied_opid_in_snapshot_info | ||
1 | ||
SET @@global.include_applied_opid_in_snapshot_info = false; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
@@global.include_applied_opid_in_snapshot_info | ||
0 | ||
SET @@global.include_applied_opid_in_snapshot_info = default; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
@@global.include_applied_opid_in_snapshot_info | ||
1 |
17 changes: 17 additions & 0 deletions
17
mysql-test/suite/sys_vars/t/include_applied_opid_in_snapshot_info_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- source include/load_sysvars.inc | ||
|
||
--echo Default value is true | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
|
||
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
SELECT @@session.include_applied_opid_in_snapshot_info; | ||
--echo Expected error 'Variable is a GLOBAL variable' | ||
|
||
SET @@global.include_applied_opid_in_snapshot_info = true; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
|
||
SET @@global.include_applied_opid_in_snapshot_info = false; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; | ||
|
||
SET @@global.include_applied_opid_in_snapshot_info = default; | ||
SELECT @@global.include_applied_opid_in_snapshot_info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters