| 1 |
--source include/galera_cluster.inc |
| 2 |
--source include/big_test.inc |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
|
| 5 |
# |
| 6 |
# To have real concurrent CTAS this test uses DEBUG_SYNC |
| 7 |
# |
| 8 |
|
| 9 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 10 |
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 11 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 12 |
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 13 |
|
| 14 |
--connection node_1 |
| 15 |
# |
| 16 |
# Send CTAS it will block before open_tables call |
| 17 |
# |
| 18 |
SET DEBUG_SYNC = 'wsrep_create_table_as_select WAIT_FOR continue'; |
| 19 |
--send CREATE table t1 as SELECT SLEEP(0.1); |
| 20 |
|
| 21 |
--connection node_1a |
| 22 |
# |
| 23 |
# Wait for CTAS to block |
| 24 |
# |
| 25 |
--echo # Wait until CTAS is on debug sync point |
| 26 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: wsrep_create_table_as_select' |
| 27 |
--source include/wait_condition.inc |
| 28 |
|
| 29 |
--connection node_1b |
| 30 |
# |
| 31 |
# Block node_1 applier |
| 32 |
# |
| 33 |
SET SESSION wsrep_sync_wait = 0; |
| 34 |
SET GLOBAL debug_dbug = '+d,sync.wsrep_apply_cb'; |
| 35 |
|
| 36 |
# |
| 37 |
# Send concurrent CTAS it will block on applier |
| 38 |
# |
| 39 |
--connection node_2 |
| 40 |
--send CREATE table t1 as SELECT SLEEP(0.2); |
| 41 |
|
| 42 |
# |
| 43 |
# Wait until second CTAS is blocked |
| 44 |
# |
| 45 |
--connection node_1b |
| 46 |
SET SESSION debug_sync = 'now WAIT_FOR sync.wsrep_apply_cb_reached'; |
| 47 |
|
| 48 |
--echo # Signal first CTAS to continue and wait until CTAS has executed |
| 49 |
SET DEBUG_SYNC= 'now SIGNAL continue'; |
| 50 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Creating table CREATE table t1 as SELECT SLEEP(0.1)' |
| 51 |
--source include/wait_condition.inc |
| 52 |
|
| 53 |
--connection node_2b |
| 54 |
--echo # Wait first CTAS to replicate |
| 55 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' |
| 56 |
--source include/wait_condition.inc |
| 57 |
SELECT * FROM t1; |
| 58 |
|
| 59 |
--connection node_1b |
| 60 |
# |
| 61 |
# Release second CTAS and cleanup |
| 62 |
# |
| 63 |
SET GLOBAL debug_dbug= ''; |
| 64 |
SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; |
| 65 |
# |
| 66 |
# Wait until second CTAS continues |
| 67 |
# |
| 68 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'debug sync point: now%' |
| 69 |
--source include/wait_condition.inc |
| 70 |
# |
| 71 |
# Wait until second CTAS finishes |
| 72 |
# |
| 73 |
--connection node_2a |
| 74 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Creating table CREATE table t1 as SELECT SLEEP(0.2)' |
| 75 |
--source include/wait_condition.inc |
| 76 |
# |
| 77 |
# Cleanup |
| 78 |
# |
| 79 |
--connection node_1b |
| 80 |
SET DEBUG_SYNC= 'RESET'; |
| 81 |
# |
| 82 |
# Verify that at least one is successful |
| 83 |
# |
| 84 |
--connection node_2 |
| 85 |
--reap |
| 86 |
SELECT * FROM t1; |
| 87 |
|
| 88 |
--connection node_1 |
| 89 |
--error 0,ER_QUERY_INTERRUPTED,ER_LOCK_DEADLOCK |
| 90 |
--reap |
| 91 |
SELECT * FROM t1; |
| 92 |
DROP TABLE t1; |
| 93 |
|
| 94 |
--disconnect node_1a |
| 95 |
--disconnect node_1b |
| 96 |
--disconnect node_2a |
| 97 |
--disconnect node_2b |
| 98 |
|
| 99 |
--source include/galera_end.inc |
| 100 |
--echo # End of test |