| 1 |
# |
| 2 |
# Test case for BUG#30198097 |
| 3 |
# |
| 4 |
|
| 5 |
--source include/have_binlog_format_row.inc |
| 6 |
--source include/master-slave.inc |
| 7 |
|
| 8 |
--source include/rpl_connection_master.inc |
| 9 |
--let $saved_master_binlog_transaction_compression=`SELECT @@session.binlog_transaction_compression` |
| 10 |
SET @@session.binlog_transaction_compression = ON; |
| 11 |
|
| 12 |
--source include/rpl_connection_slave.inc |
| 13 |
--let $saved_replica_transaction_retries = `SELECT @@global.replica_transaction_retries` |
| 14 |
--let $saved_innodb_lock_wait_timeout = `SELECT @@global.innodb_lock_wait_timeout` |
| 15 |
--let $saved_replica_parallel_workers = `SELECT @@global.replica_parallel_workers` |
| 16 |
--let $saved_replica_parallel_type = `SELECT @@global.replica_parallel_type` |
| 17 |
--let $saved_binlog_transaction_compression = `SELECT @@global.binlog_transaction_compression` |
| 18 |
--let $saved_replica_preserve_commit_order = `SELECT @@global.replica_preserve_commit_order` |
| 19 |
--source include/stop_slave_sql.inc |
| 20 |
SET @@global.replica_transaction_retries= 200; |
| 21 |
SET @@global.innodb_lock_wait_timeout= 5; |
| 22 |
SET @@global.binlog_transaction_compression = ON; |
| 23 |
SET @@global.replica_parallel_workers = 4; |
| 24 |
SET @@global.replica_preserve_commit_order = OFF; |
| 25 |
--source include/start_slave_sql.inc |
| 26 |
|
| 27 |
--let $j = 3 |
| 28 |
while ($j > 0) { |
| 29 |
|
| 30 |
if ($j == 1) { |
| 31 |
--let $nworkers = 0 |
| 32 |
} |
| 33 |
|
| 34 |
if ($j == 2) { |
| 35 |
--let $nworkers = 1 |
| 36 |
} |
| 37 |
|
| 38 |
if ($j == 3) { |
| 39 |
--let $nworkers = 8 |
| 40 |
} |
| 41 |
|
| 42 |
--source include/stop_slave_sql.inc |
| 43 |
--eval SET @@global.replica_parallel_workers = $nworkers |
| 44 |
--source include/start_slave_sql.inc |
| 45 |
|
| 46 |
--let $i = 2 |
| 47 |
while($i>0) |
| 48 |
{ |
| 49 |
|
| 50 |
if ($i == 2) |
| 51 |
{ |
| 52 |
--let $replica_parallel_type = 'DATABASE' |
| 53 |
} |
| 54 |
|
| 55 |
if ($i == 1) |
| 56 |
{ |
| 57 |
--let $replica_parallel_type = 'LOGICAL_CLOCK' |
| 58 |
} |
| 59 |
|
| 60 |
--source include/rpl_connection_master.inc |
| 61 |
--source include/rpl_reset.inc |
| 62 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT); |
| 63 |
--source include/sync_slave_sql_with_master.inc |
| 64 |
|
| 65 |
--source include/stop_slave_sql.inc |
| 66 |
--eval SET @@global.replica_parallel_type = $replica_parallel_type |
| 67 |
--source include/start_slave_sql.inc |
| 68 |
|
| 69 |
--source include/rpl_connection_slave1.inc |
| 70 |
BEGIN; |
| 71 |
INSERT INTO t1 SET a = 10, b = 11; |
| 72 |
|
| 73 |
--source include/rpl_connection_master.inc |
| 74 |
|
| 75 |
INSERT INTO t1 SET a = 22, b = 22; |
| 76 |
XA START 'xa1'; |
| 77 |
INSERT INTO t1 SET a = 10, b = 1; |
| 78 |
XA END 'xa1'; |
| 79 |
XA PREPARE 'xa1'; |
| 80 |
|
| 81 |
# assert that we have transactions were compressed |
| 82 |
--let $include_trx_payload_events=1 |
| 83 |
--let $event_sequence = Gtid # Query # Gtid # Transaction_payload # Query # Table_map # Write_rows # Xid # Gtid # Transaction_payload # Query/XA START.* # Table_map # Write_rows # Query/XA END.* # XA_prepare |
| 84 |
--source include/assert_binlog_events.inc |
| 85 |
--let $include_trx_payload_events=0 |
| 86 |
|
| 87 |
--source include/rpl_connection_slave.inc |
| 88 |
|
| 89 |
# wait for the applier thread to start applying |
| 90 |
--let $wait_condition=SELECT COUNT(*) > 0 FROM performance_schema.threads WHERE name IN ("thread/sql/replica_sql", "thread/sql/replica_worker") AND processlist_info LIKE 'XA START%' |
| 91 |
--source include/wait_condition.inc |
| 92 |
|
| 93 |
# get the exact thread id for the applier thread |
| 94 |
--let $worker_thread_id=`SELECT thread_id FROM performance_schema.threads WHERE name IN ("thread/sql/replica_sql", "thread/sql/replica_worker") AND processlist_info LIKE 'XA START%'` |
| 95 |
|
| 96 |
# wait for the applier thread to start retrying |
| 97 |
--let $wait_condition=SELECT APPLYING_TRANSACTION_RETRIES_COUNT > 0 FROM performance_schema.replication_applier_status_by_worker WHERE thread_id = $worker_thread_id |
| 98 |
--source include/wait_condition.inc |
| 99 |
|
| 100 |
--source include/rpl_connection_slave1.inc |
| 101 |
|
| 102 |
ROLLBACK; |
| 103 |
|
| 104 |
--source include/rpl_connection_master.inc |
| 105 |
XA COMMIT 'xa1'; |
| 106 |
--source include/sync_slave_sql_with_master.inc |
| 107 |
|
| 108 |
# assert that we have the expected event sequence in the |
| 109 |
# slave's binary log |
| 110 |
--let $include_trx_payload_events=1 |
| 111 |
--let $event_sequence = Gtid # Query # Gtid # Transaction_payload # Query # Table_map # Write_rows # Xid # Gtid # Transaction_payload # Query/XA START.* # Table_map # Write_rows # Query/XA END.* # XA_prepare # Gtid # Query/XA COMMIT.* |
| 112 |
--source include/assert_binlog_events.inc |
| 113 |
|
| 114 |
# assert that the tables have the same content |
| 115 |
--let $diff_tables=master:test.t1,slave:test.t1 |
| 116 |
--source include/diff_tables.inc |
| 117 |
|
| 118 |
--source include/rpl_connection_master.inc |
| 119 |
DROP TABLE t1; |
| 120 |
--source include/sync_slave_sql_with_master.inc |
| 121 |
|
| 122 |
--dec $i |
| 123 |
} |
| 124 |
|
| 125 |
--dec $j |
| 126 |
} |
| 127 |
|
| 128 |
--source include/stop_slave.inc |
| 129 |
|
| 130 |
--replace_result $saved_replica_transaction_retries SAVED |
| 131 |
--eval SET @@global.replica_transaction_retries= $saved_replica_transaction_retries |
| 132 |
--replace_result $saved_innodb_lock_wait_timeout SAVED |
| 133 |
--eval SET @@global.innodb_lock_wait_timeout= $saved_innodb_lock_wait_timeout |
| 134 |
--replace_result $saved_binlog_transaction_compression SAVED |
| 135 |
--eval SET @@global.binlog_transaction_compression = $saved_binlog_transaction_compression |
| 136 |
--disable_warnings |
| 137 |
--replace_result $saved_replica_parallel_workers SAVED |
| 138 |
--eval SET @@global.replica_parallel_workers = $saved_replica_parallel_workers |
| 139 |
--enable_warnings |
| 140 |
--replace_result $saved_replica_parallel_type SAVED |
| 141 |
--eval SET @@global.replica_parallel_type = '$saved_replica_parallel_type' |
| 142 |
--replace_result $saved_replica_preserve_commit_order SAVED |
| 143 |
--eval SET @@global.replica_preserve_commit_order = $saved_replica_preserve_commit_order |
| 144 |
--source include/start_slave.inc |
| 145 |
|
| 146 |
--source include/rpl_connection_master.inc |
| 147 |
--replace_result $saved_master_binlog_transaction_compression SAVED |
| 148 |
--eval SET @@session.binlog_transaction_compression = $saved_master_binlog_transaction_compression |
| 149 |
|
| 150 |
--source include/rpl_end.inc |