-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix partial trx condition when waiting for workers to finish
Summary: After per DB commit ordering in D13086060, we buffer transactions in the SQL thread until we find an event that contains DB information. While syncing transactions (like DDL which need to be executed in isolation) we need to use the `trx_queued` flag to figure out if we need to factor in a partial transaction (i.e. a transaction which is not fully parsed by SQL thread yet), otherwise race conditions can occur because SQL thread will not wait for all transactions to complete before queuing the sync transaction. In the case of DDL, the race condition can cause the DDL to run before a conflicting trx, this will cause a deadlock because of commit ordering or MDL locks. Reviewed By: anirbanr-fb Differential Revision: D16590942 fbshipit-source-id: 32ef00f
- Loading branch information
1 parent
c42081d
commit 85c6ed5
Showing
7 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
mysql-test/suite/rpl_mts/r/rpl_mts_dependency_ddl_stress.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,13 @@ | ||
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] | ||
STOP SLAVE SQL_THREAD; | ||
create table t1(a int auto_increment primary key) engine = innodb; | ||
start slave sql_thread; | ||
include/sync_slave_sql_with_master.inc | ||
include/diff_tables.inc [master:test.t1, slave:test.t1] | ||
drop table t1; | ||
include/sync_slave_sql_with_master.inc | ||
include/rpl_end.inc |
1 change: 1 addition & 0 deletions
1
mysql-test/suite/rpl_mts/t/rpl_mts_dependency_ddl_stress-master.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 @@ | ||
--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates |
2 changes: 2 additions & 0 deletions
2
mysql-test/suite/rpl_mts/t/rpl_mts_dependency_ddl_stress-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 @@ | ||
--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates | ||
--slave_parallel_workers=16 |
93 changes: 93 additions & 0 deletions
93
mysql-test/suite/rpl_mts/t/rpl_mts_dependency_ddl_stress.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,93 @@ | ||
source include/master-slave.inc; | ||
source include/have_mts_dependency_replication.inc; | ||
source include/big_test.inc; | ||
source include/not_valgrind.inc; | ||
|
||
connection slave; | ||
STOP SLAVE SQL_THREAD; | ||
|
||
# generate load | ||
connection master; | ||
create table t1(a int auto_increment primary key) engine = innodb; | ||
|
||
disable_query_log; | ||
let $iter = 10000; | ||
let $col_inc = 0; | ||
while ($iter > 0) | ||
{ | ||
let $rand= `select round(rand() * 100)`; | ||
# execute a DDL 20% of the time | ||
if ($rand < 20) | ||
{ | ||
let $inner_rand= `select round(rand() * 100)`; | ||
if ($inner_rand < 25) | ||
{ | ||
drop table t1; | ||
create table t1(a int auto_increment primary key) engine = innodb; | ||
} | ||
if ($inner_rand >= 25 && $inner_rand < 50) | ||
{ | ||
eval alter table t1 add column b_$col_inc int; | ||
inc $col_inc; | ||
} | ||
if ($inner_rand >= 50 && $inner_rand < 75) | ||
{ | ||
let $c= `select column_name from information_schema.columns where | ||
table_name = 't1' and column_name not like 'a%' limit 1`; | ||
if ($c != "") | ||
{ | ||
eval alter table t1 drop column $c; | ||
} | ||
} | ||
if ($inner_rand >= 75) | ||
{ | ||
let $c= `select column_name from information_schema.columns where | ||
table_name = 't1' and column_name not like 'a%' limit 1`; | ||
if ($c != "") | ||
{ | ||
eval alter table t1 modify $c bigint; | ||
} | ||
} | ||
} | ||
# Execute DML 80% of the time | ||
if ($rand >= 20) | ||
{ | ||
let $inner_rand2= `select round(rand() * 100)`; | ||
if ($inner_rand2 < 33) | ||
{ | ||
insert into t1 values(); | ||
} | ||
if ($inner_rand2 >= 33 && $inner_rand2 < 66) | ||
{ | ||
delete from t1 limit 1; | ||
} | ||
if ($inner_rand2 >= 66) | ||
{ | ||
let $c= `select column_name from information_schema.columns where | ||
table_name = 't1' and column_name not like 'a%' limit 1`; | ||
if ($c != "") | ||
{ | ||
eval update t1 set $c = a; | ||
} | ||
} | ||
} | ||
dec $iter; | ||
} | ||
enable_query_log; | ||
|
||
connection slave; | ||
start slave sql_thread; | ||
|
||
connection master; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
# Check if master and slave have the same data | ||
let $diff_tables=master:test.t1, slave:test.t1; | ||
source include/diff_tables.inc; | ||
|
||
# Cleanup | ||
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