-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support commit order deadlocks resolution in dependency replication
Summary: This is a port of D28619160 (facebook/mysql-5.6@ce8c474) Reviewed By: hermanlee Differential Revision: D28974185 fbshipit-source-id: 4139ad303f8
- Loading branch information
1 parent
9fbe1c1
commit d11fc6b
Showing
15 changed files
with
259 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (`SELECT @@GLOBAL.mts_dependency_replication != 'STMT'`) { | ||
skip Test needs to run with STMT dependency replication; | ||
} |
21 changes: 21 additions & 0 deletions
21
mysql-test/suite/innodb/r/innodb_row_lock_wait_callback.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,21 @@ | ||
create table t1 (a int primary key, b int unique, c int) engine = innodb; | ||
insert into t1 values(1, 1, 1); | ||
insert into t1 values(10, 10, 10); | ||
set @@global.debug = "+d,report_row_lock_wait"; | ||
select @@tx_isolation; | ||
@@tx_isolation | ||
REPEATABLE-READ | ||
begin; | ||
delete from t1 where a > 5; | ||
begin; | ||
insert into t1 values(6, 6, 6); | ||
set debug_sync="now wait_for signal.reached"; | ||
set debug_sync="now signal signal.done"; | ||
set @@global.debug = "-d,report_row_lock_wait"; | ||
rollback; | ||
select * from t1; | ||
a b c | ||
1 1 1 | ||
6 6 6 | ||
10 10 10 | ||
drop table t1; |
30 changes: 30 additions & 0 deletions
30
mysql-test/suite/innodb/t/innodb_row_lock_wait_callback.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,30 @@ | ||
source include/have_debug.inc; | ||
#source include/have_innodb.inc; | ||
source include/have_debug_sync.inc; | ||
|
||
create table t1 (a int primary key, b int unique, c int) engine = innodb; | ||
insert into t1 values(1, 1, 1); | ||
insert into t1 values(10, 10, 10); | ||
set @@global.debug = "+d,report_row_lock_wait"; | ||
|
||
select @@tx_isolation; | ||
|
||
connect (con1, localhost, root); | ||
begin; | ||
delete from t1 where a > 5; # this will take a gap lock | ||
|
||
connection default; | ||
begin; | ||
send insert into t1 values(6, 6, 6); # this will block on gap lock | ||
|
||
connection con1; | ||
set debug_sync="now wait_for signal.reached"; # callback was fired | ||
set debug_sync="now signal signal.done"; | ||
set @@global.debug = "-d,report_row_lock_wait"; | ||
rollback; | ||
disconnect con1; | ||
|
||
connection default; | ||
reap; | ||
select * from t1; | ||
drop table t1; |
33 changes: 33 additions & 0 deletions
33
mysql-test/suite/rpl_mts/r/rpl_mts_dependency_order_commits_deadlock.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,33 @@ | ||
include/master-slave.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[connection master] | ||
call mtr.add_suppression("Commit order deadlock between"); | ||
create table t1 (a int primary key, b int) engine = innodb; | ||
insert into t1 values(3, 3); | ||
include/sync_slave_sql_with_master.inc | ||
stop slave; | ||
set @@global.debug = "+d,dbug.dep_fake_gap_lock_on_insert"; | ||
begin; | ||
insert into t1 values(1, 1); | ||
insert into t1 values(1, 1); | ||
insert into t1 values(2, 2); | ||
update t1 set b = 20 where a = 2; | ||
update t1 set b = 200 where a = 2; | ||
update t1 set b = 30 where a = 3; | ||
update t1 set b = 300 where a = 3; | ||
start slave; | ||
rollback; | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
a b | ||
1 1 | ||
2 200 | ||
3 300 | ||
stop slave; | ||
set @@global.debug = "-d,dbug.dep_fake_gap_lock_on_insert"; | ||
start slave; | ||
drop table t1; | ||
include/sync_slave_sql_with_master.inc | ||
include/rpl_end.inc |
2 changes: 2 additions & 0 deletions
2
mysql-test/suite/rpl_mts/t/rpl_mts_dependency_order_commits_deadlock-slave.opt
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,2 @@ | ||
--slave_check_before_image_consistency=ON | ||
--slave_parallel_workers=8 |
68 changes: 68 additions & 0 deletions
68
mysql-test/suite/rpl_mts/t/rpl_mts_dependency_order_commits_deadlock.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,68 @@ | ||
source include/master-slave.inc; | ||
source include/have_mts_dependency_replication_stmt.inc; | ||
source include/have_debug.inc; | ||
|
||
call mtr.add_suppression("Commit order deadlock between"); | ||
|
||
connection master; | ||
create table t1 (a int primary key, b int) engine = innodb; | ||
insert into t1 values(3, 3); | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
connection slave; | ||
stop slave; | ||
# We'll take a fake gap lock after execution of every insert event | ||
set @@global.debug = "+d,dbug.dep_fake_gap_lock_on_insert"; | ||
|
||
# Start a trx to block the 1st insert that primary will send to create a gap in | ||
# commit order | ||
begin; | ||
insert into t1 values(1, 1); | ||
|
||
connection master; | ||
insert into t1 values(1, 1); # this will be blocked by trx above | ||
insert into t1 values(2, 2); # this will take the fake gap lock and wait for commit order | ||
update t1 set b = 20 where a = 2; # this will wait for above trx due to deps | ||
update t1 set b = 200 where a = 2; # this will wait for above trx due to deps | ||
update t1 set b = 30 where a = 3; # this will wait for commit order | ||
update t1 set b = 300 where a = 3; # this will wait for above trx due to deps | ||
|
||
connection slave1; | ||
start slave; | ||
# Wait for the 2nd and 5th trx to start waiting for commit ordering | ||
let $wait_condition= SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST | ||
WHERE STATE LIKE "%Waiting for preceding transaction to commit%"; | ||
let $wait_timeout= 120; | ||
source include/wait_condition.inc; | ||
|
||
# Wait for the 3rd, 4th and 6th trx to wait for dependencies | ||
let $wait_condition= SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.PROCESSLIST | ||
WHERE STATE LIKE "%Waiting for dependencies to be satisfied%"; | ||
let $wait_timeout= 120; | ||
source include/wait_condition.inc; | ||
|
||
connection slave; | ||
# unblock 1st insert trx, it'll try to lock fake gap and fire the callback | ||
rollback; | ||
|
||
# Wait for 2nd transcation to be retried after receiving the commit order | ||
# deadlock signal | ||
let $wait_condition= SELECT VARIABLE_VALUE = 1 FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Slave_commit_order_deadlocks'; | ||
let $wait_timeout= 120; | ||
source include/wait_condition.inc; | ||
|
||
connection master; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
connection slave; | ||
select * from t1; | ||
|
||
stop slave; | ||
set @@global.debug = "-d,dbug.dep_fake_gap_lock_on_insert"; | ||
start slave; | ||
|
||
connection master; | ||
drop table t1; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
source include/rpl_end.inc; |
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
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
Oops, something went wrong.