1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
################################################################################
# WL#6833: GCS Replication: Read-set free Certification
# Module (DBSM Snapshot Isolation)
#
# Scenario 4: Check that certifier garbage collector don't remove needed
# certification info to detect conflicting transactions.
#
# Verify Group Replication certifier garbage collection behavior when we have a
# slow applying member, that is, server 2 certifies transactions but is unable
# to apply remote transactions.
#
# Test:
# 0. The test requires two servers: M1 and M2.
# 1. Both members are ONLINE. Execute two transactions on M1 and wait until they
# are applied on all group members.
# 2. Block M2 group replication applier so that certified remote transactions not
# applied. This will mimic a slow server.
# 3. Commit a transaction(T1) on M1, that will be certified on both members but
# only applied on M1
# 4. Wait until M2 receives and certifies T1.
# 5. Wait for stable set propagation and certification info garbage collection.
# After garbage collection certification info will contain:
# WS: t1.c1=1 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
# WS: t1.c1=2 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
# 6. Execute the same statement of T1 in M2, now named T2. It must be aborted
# since it conflicts with T1, despite it is not yet applied on M2.
# Snapshot of T2 is: 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
# 7. Resume M2 group replication applier so that certified remote transactions
# are applied. Wait until all group transactions are applied.
# 8. Execute a transaction on M2 to verify that everything is OK.
# 9. Check that GTID_EXECUTED on M1 contains all transactions. Also check that
# data is on tables.
# 10. Check that GTID_EXECUTED on M2 contains all transactions. Also check that
# data is on tables.
# 11. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_debug_sync.inc
--source include/have_group_replication_gtid_assignment_block_size_1.inc
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9422222
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
# Keep binary logs with only GTIDs from test.
--connection server1
SET SESSION sql_log_bin= 0;
--source include/gtid_utils.inc
SET SESSION sql_log_bin= 1;
--connection server2
SET SESSION sql_log_bin= 0;
--source include/gtid_utils.inc
SET SESSION sql_log_bin= 1;
--echo
--echo ############################################################
--echo # 1. Execute two transactions on server 1 and wait until
--echo # they are applied on all group members.
--connection server1
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--source include/rpl_sync.inc
--echo
--echo ############################################################
--echo # 2. Block server 2 group replication applier so that
--echo # certified remote transactions are not applied.
--echo # This will mimic a slow server.
--connection server2
SET @@GLOBAL.DEBUG='+d,block_applier_updates';
--echo
--echo ############################################################
--echo # 3. Commit a transaction (T1) on server 1, that will be
--echo # certified on both members but only applied on server 1.
--connection server1
--let $assert_text= GTID_EXECUTED must contain first two transactions plus the view changes
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-4")
--source include/assert.inc
UPDATE t1 SET c1=2 WHERE c1=1;
--echo
--echo ############################################################
--echo # 4. Wait until server 2 receives and certifies T1.
--connection server2
--let $wait_condition= SELECT Last_Conflict_Free_Transaction = '8a94f357-aab4-11df-86ab-c80aa9422222:5' from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)
--source include/wait_condition.inc
--echo
--echo ############################################################
--echo # 5. Wait for stable set propagation and certification info
--echo # garbage collection.
--echo # After garbage collection certification info will contain:
--echo # WS: t1.c1=1 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
--echo # WS: t1.c1=2 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
--connection server1
--let $wait_timeout= 65
--let $wait_condition= SELECT Transactions_committed_all_members<>"" FROM performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)
--source include/wait_condition.inc
--connection server1
--let $count_transactions_validating= query_get_value(SELECT Count_transactions_rows_validating from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_transactions_rows_validating, 1)
--let $assert_text= 'Count_transactions_rows_validating must be 2'
--let $assert_cond= $count_transactions_validating = 2
--source include/assert.inc
--let $transactions_committed_all_members= query_get_value(SELECT Transactions_committed_all_members from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Transactions_committed_all_members, 1)
--let $assert_text= 'Transactions_committed_all_members must be equal to $group_replication_group_name:1-4'
--let $assert_cond= GTID_IS_EQUAL("$transactions_committed_all_members", "$group_replication_group_name:1-4")
--source include/assert.inc
--connection server2
--let $count_transactions_validating= query_get_value(SELECT Count_transactions_rows_validating from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_transactions_rows_validating, 1)
--let $assert_text= 'Count_transactions_rows_validating must be 2'
--let $assert_cond= $count_transactions_validating = 2
--source include/assert.inc
--let $transactions_committed_all_members= query_get_value(SELECT Transactions_committed_all_members from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Transactions_committed_all_members, 1)
--let $assert_text= 'Transactions_committed_all_members must be equal to $group_replication_group_name:1-4'
--let $assert_cond= GTID_IS_EQUAL("$transactions_committed_all_members", "$group_replication_group_name:1-4")
--source include/assert.inc
--echo
--echo ############################################################
--echo # 6. Execute the same statement of T1 in server 2, now named T2.
--echo # It must be aborted since it conflicts with T1, despite
--echo # it is not yet applied on server 2. Snapshot of T2 is
--echo # 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
--connection server2
--let $assert_text= GTID_EXECUTED must contain first two transactions
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-4")
--source include/assert.inc
--error ER_TRANSACTION_ROLLBACK_DURING_COMMIT
UPDATE t1 SET c1=2 WHERE c1=1;
--let $assert_text= 'There is a value 1 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
--source include/assert.inc
--let $assert_text= 'There is no value 2 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 0
--source include/assert.inc
--echo
--echo ############################################################
--echo # 7. Start server 2 group replication applier so that
--echo # certified remote transactions are applied.
--echo # Wait until all group transactions are applied.
--connection server2
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
SET @@GLOBAL.DEBUG='-d,block_applier_updates';
SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
--source include/rpl_sync.inc
--echo
--echo ############################################################
--echo # 8. Execute a transaction on server 2 to verify that
--echo # everything is OK.
--connection server2
--let $assert_text= GTID_EXECUTED must contain all group transactions
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-5")
--source include/assert.inc
UPDATE t1 SET c1=3 WHERE c1=2;
--source include/rpl_sync.inc
--echo ############################################################
--echo # 9. Check that GTID_EXECUTED on server 1 contains all
--echo # transactions.
--echo # Also check that data is on tables.
--connection server1
--let $assert_text= GTID_EXECUTED must contain all committed GTIDs
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-6")
--source include/assert.inc
--let $assert_text= 'There is a value 3 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1
--source include/assert.inc
--echo ############################################################
--echo # 10. Check that GTID_EXECUTED on server 2 contains all
--echo # transactions.
--echo # Also check that data is on tables.
--connection server2
--let $assert_text= GTID_EXECUTED must contain all committed GTIDs
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-6")
--source include/assert.inc
--let $assert_text= 'There is a value 3 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1
--source include/assert.inc
--echo
--echo ############################################################
--echo # 11. Clean up.
DROP TABLE t1;
--connection server1
SET SESSION sql_log_bin= 0;
--source include/gtid_utils_end.inc
SET SESSION sql_log_bin= 1;
--connection server2
SET SESSION sql_log_bin= 0;
--source include/gtid_utils_end.inc
SET SESSION sql_log_bin= 1;
SET DEBUG_SYNC= 'RESET';
--source include/group_replication_end.inc
|