| 1 |
# |
| 2 |
# Test that bulk insert replicates as table-level exclusive key and |
| 3 |
# rolls back properly if needed. |
| 4 |
# |
| 5 |
|
| 6 |
--source include/galera_cluster.inc |
| 7 |
--source include/have_innodb.inc |
| 8 |
--source include/have_debug_sync.inc |
| 9 |
--source include/have_debug.inc |
| 10 |
|
| 11 |
# |
| 12 |
# Make bulk insert BF-abort, but regular insert succeed. |
| 13 |
# |
| 14 |
|
| 15 |
--connection node_1 |
| 16 |
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 17 |
|
| 18 |
# Delay applying of the single insert from the other node. |
| 19 |
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb'; |
| 20 |
|
| 21 |
--connection node_1 |
| 22 |
# Disable foreign and unique key checks to allow bulk insert. |
| 23 |
SET foreign_key_checks = 0; |
| 24 |
SET unique_checks = 0; |
| 25 |
|
| 26 |
START TRANSACTION; |
| 27 |
|
| 28 |
--let $count=0 |
| 29 |
--disable_query_log |
| 30 |
while ($count < 1000) |
| 31 |
{ |
| 32 |
--eval INSERT INTO t1 VALUES ($count) |
| 33 |
--inc $count |
| 34 |
} |
| 35 |
--enable_query_log |
| 36 |
|
| 37 |
--connection node_2 |
| 38 |
|
| 39 |
# Disable bulk insert on this node. |
| 40 |
SET foreign_key_checks = 1; |
| 41 |
SET unique_checks = 1; |
| 42 |
|
| 43 |
# Insert a value out of the bulk insert range. |
| 44 |
INSERT INTO t1 VALUES (1001); |
| 45 |
|
| 46 |
--connection node_1 |
| 47 |
|
| 48 |
# We need to trigger Galera-level certification conflict. For this: |
| 49 |
# - start applying single insert from the other node before bulk insert certifies |
| 50 |
# - certifying bulk insert will lead to the conflict |
| 51 |
# - keep applying single insert |
| 52 |
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached'; |
| 53 |
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb'; |
| 54 |
|
| 55 |
--error ER_LOCK_DEADLOCK |
| 56 |
COMMIT; |
| 57 |
|
| 58 |
DROP TABLE t1; |
| 59 |
SET GLOBAL DEBUG_DBUG = ''; |
| 60 |
SET DEBUG_SYNC = 'RESET'; |
| 61 |
|
| 62 |
# |
| 63 |
# Make bulk insert succeed, but regular insert BF-abort. |
| 64 |
# |
| 65 |
|
| 66 |
--connection node_1 |
| 67 |
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 68 |
|
| 69 |
--connection node_2 |
| 70 |
# Delay applying of the bulk insert from the other node. |
| 71 |
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb'; |
| 72 |
|
| 73 |
--connection node_1 |
| 74 |
--let $before_bulk_keys = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'` |
| 75 |
|
| 76 |
# Disable foreign and unique key checks to allow bulk insert. |
| 77 |
SET foreign_key_checks = 0; |
| 78 |
SET unique_checks = 0; |
| 79 |
|
| 80 |
START TRANSACTION; |
| 81 |
|
| 82 |
--let $count=0 |
| 83 |
--disable_query_log |
| 84 |
while ($count < 1000) |
| 85 |
{ |
| 86 |
--eval INSERT INTO t1 VALUES ($count) |
| 87 |
--inc $count |
| 88 |
} |
| 89 |
--enable_query_log |
| 90 |
|
| 91 |
--connection node_2 |
| 92 |
# Disable bulk insert on this node. |
| 93 |
SET foreign_key_checks = 1; |
| 94 |
SET unique_checks = 1; |
| 95 |
|
| 96 |
START TRANSACTION; |
| 97 |
|
| 98 |
# Insert a value out of the bulk insert range. |
| 99 |
INSERT INTO t1 VALUES (1001); |
| 100 |
|
| 101 |
--connection node_1 |
| 102 |
COMMIT; |
| 103 |
|
| 104 |
# Expect three keys to be added for bulk insert: "zero-level" key, DB-level shared key and table-level exclusive key. |
| 105 |
--let $bulk_keys_count = `SELECT VARIABLE_VALUE - $before_bulk_keys FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'` |
| 106 |
--echo $bulk_keys_count |
| 107 |
|
| 108 |
--connection node_2 |
| 109 |
|
| 110 |
# We need to trigger Galera-level certification conflict. For this: |
| 111 |
# - start applying bulk insert from the other node before local insert certifies |
| 112 |
# - certifying local insert will lead to the conflict |
| 113 |
# - keep applying bulk insert |
| 114 |
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached'; |
| 115 |
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb'; |
| 116 |
|
| 117 |
--error ER_LOCK_DEADLOCK |
| 118 |
COMMIT; |
| 119 |
|
| 120 |
DROP TABLE t1; |
| 121 |
SET GLOBAL DEBUG_DBUG = ''; |
| 122 |
SET DEBUG_SYNC = 'RESET'; |
| 123 |
--source include/galera_end.inc |