| 1 |
############################################################################### |
| 2 |
# ==== Purpose ==== |
| 3 |
# The purpose of this test is to verify that replication does not enter a |
| 4 |
# deadlock state when the relay log exceeds `relay_log_space_limit` while |
| 5 |
# `LOCK INSTANCE FOR BACKUP` is held on the replica. |
| 6 |
# |
| 7 |
# ==== Requirement ==== |
| 8 |
# Replication shall resume normal operation and make forward progress after the |
| 9 |
# backup lock is released when the relay log exceeds `relay_log_space_limit` |
| 10 |
# while `LOCK INSTANCE FOR BACKUP` is held on the replica. |
| 11 |
# |
| 12 |
# ==== Implementation ==== |
| 13 |
# 1. Create a source-replica topology. |
| 14 |
# 2. Prepare initial test data and ensure it is replicated. |
| 15 |
# 3. Take backup lock on the replica. |
| 16 |
# 4. Generate a transaction that exceeds the relay log space limit. |
| 17 |
# 5. Verify that the receiver thread is waiting for applier thread to free relay |
| 18 |
# log space. |
| 19 |
# 6. Unlock the replica instance. |
| 20 |
# 7. Verify that the receiver thread is waiting for the source to send events. |
| 21 |
# 8. Verify that the files slave-relay-bin.000001 and slave-relay-bin.000002 |
| 22 |
# have been deleted (purged) to free relay log space. |
| 23 |
# 9. Synchronize the source and replica servers. |
| 24 |
# 10. Clean up. |
| 25 |
# |
| 26 |
# ==== References ==== |
| 27 |
# Bug#38775593:channel does not resume after reaching relay_log_space_limit |
| 28 |
# when locked for backup |
| 29 |
################################################################################ |
| 30 |
|
| 31 |
--source include/have_binlog_format_row.inc |
| 32 |
|
| 33 |
# This test case requires a deterministic relay log size. |
| 34 |
# Therefore, cannot run with compression on. |
| 35 |
--source include/not_binlog_transaction_compression_on.inc |
| 36 |
|
| 37 |
--echo |
| 38 |
--echo # 1. Create a source-replica topology. |
| 39 |
--echo |
| 40 |
--source include/master-slave.inc |
| 41 |
|
| 42 |
--echo |
| 43 |
--echo # 2. Prepare initial test data and ensure it is replicated. |
| 44 |
--echo |
| 45 |
--source include/rpl_connection_master.inc |
| 46 |
CREATE TABLE t (a LONGBLOB) ENGINE = InnoDB; |
| 47 |
INSERT INTO t VALUES (REPEAT('a', 1000)); |
| 48 |
--source include/sync_slave_sql_with_master.inc |
| 49 |
|
| 50 |
call mtr.add_suppression("Could not purge binary logs since an.*"); |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo # 3. Take backup lock on the replica. |
| 54 |
--echo |
| 55 |
--source include/rpl_connection_slave.inc |
| 56 |
LOCK INSTANCE FOR BACKUP; |
| 57 |
|
| 58 |
--echo |
| 59 |
--echo # 4. Generate a transaction that exceeds the relay log space limit. |
| 60 |
--echo |
| 61 |
--source include/rpl_connection_master.inc |
| 62 |
INSERT INTO t VALUES (REPEAT('a', 10000)); |
| 63 |
|
| 64 |
--echo |
| 65 |
--echo # 5. Verify that the receiver thread is waiting for applier thread to |
| 66 |
--echo # free relay log space. |
| 67 |
--echo |
| 68 |
--source include/rpl_connection_slave.inc |
| 69 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name='thread/sql/replica_io' AND processlist_state= 'Waiting for the replica SQL thread to free relay log space' |
| 70 |
--source include/wait_condition.inc |
| 71 |
|
| 72 |
--echo |
| 73 |
--echo # 6. Unlock the replica instance. |
| 74 |
--echo |
| 75 |
UNLOCK INSTANCE; |
| 76 |
|
| 77 |
--echo |
| 78 |
--echo # 7. Verify that the receiver thread is waiting for the source to send |
| 79 |
--echo # events. |
| 80 |
--echo |
| 81 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name='thread/sql/replica_io' AND processlist_state= 'Waiting for source to send event' |
| 82 |
--source include/wait_condition.inc |
| 83 |
|
| 84 |
--echo |
| 85 |
--echo # 8. Verify that the files slave-relay-bin.000001 and |
| 86 |
--echo # slave-relay-bin.000002 have been deleted (purged) to free relay |
| 87 |
--echo # log space. |
| 88 |
--echo |
| 89 |
--let $DATADIR= `SELECT @@datadir` |
| 90 |
--error 1 |
| 91 |
--file_exists $DATADIR/slave-relay-bin.000001 |
| 92 |
--error 1 |
| 93 |
--file_exists $DATADIR/slave-relay-bin.000002 |
| 94 |
|
| 95 |
--echo |
| 96 |
--echo # 9. Synchronize the source and replica servers. |
| 97 |
--echo |
| 98 |
--source include/rpl_connection_master.inc |
| 99 |
--source include/sync_slave_sql_with_master.inc |
| 100 |
|
| 101 |
--echo |
| 102 |
--echo # 10. Clean up. |
| 103 |
--echo |
| 104 |
--source include/rpl_connection_master.inc |
| 105 |
DROP TABLE t; |
| 106 |
--source include/rpl_end.inc |