| 1 |
################################################################################ |
| 2 |
# WL#6839 - GCS Replication: P_S table to show DBSM stats |
| 3 |
# |
| 4 |
# This test checks the basic functionality of Group Replication |
| 5 |
# P_S for replication_group_member_stats table. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. The test requires two servers: M1 and M2. |
| 9 |
# 1. Restart the first server to erase remains of old rounds. RESET MASTER on |
| 10 |
# both M1 and M2 to delete data from previous rounds. |
| 11 |
# 2. Check output of the replication_group_member_stats table before GR start. |
| 12 |
# 3. Bootstrap and start GR on M1. Add some data. |
| 13 |
# 4. Block applier thread on M1 so that recovery blocks on M2. |
| 14 |
# 5. Start M2. Check that it is in RECOVERING state. |
| 15 |
# 6. Apply some transactions on M1 so that the queue of the M2 is not empty. |
| 16 |
# 7. Check for the transactions in the applier queue on M2. Then resume applier |
| 17 |
# thread on M1 so that recovery unblocks on M2. Check M2 is ONLINE. |
| 18 |
# 8. Check output of the replication_group_member_stats table. |
| 19 |
# 9. Clean up. Stop GR on M1 and M2. |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
--source include/big_test.inc |
| 23 |
--source include/have_debug_sync.inc |
| 24 |
--let $group_replication_group_name= 8a84f397-aaa4-18df-89ab-c70aa9823561 |
| 25 |
--source include/have_group_replication_plugin.inc |
| 26 |
|
| 27 |
--echo ################### |
| 28 |
--echo Cleanup and server setup |
| 29 |
--echo ################### |
| 30 |
|
| 31 |
#Restart the first server to erase remains of old rounds |
| 32 |
--connection server1 |
| 33 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 34 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 35 |
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds |
| 36 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS |
| 37 |
--source include/restart_mysqld.inc |
| 38 |
|
| 39 |
connect(server1_1,localhost,root,,test,$SERVER_MYPORT_1,$SERVER_MYSOCK_1); |
| 40 |
|
| 41 |
#Reset the servers to delete data from previous rounds |
| 42 |
--connection server2 |
| 43 |
--echo server2 |
| 44 |
RESET MASTER; |
| 45 |
|
| 46 |
--connection server1 |
| 47 |
--echo server1 |
| 48 |
RESET MASTER; |
| 49 |
|
| 50 |
--connection server1 |
| 51 |
--echo server1 |
| 52 |
|
| 53 |
# This is a valid name being given to the group name |
| 54 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" |
| 55 |
|
| 56 |
--echo ################### |
| 57 |
--echo Test start values |
| 58 |
--echo ################### |
| 59 |
|
| 60 |
# Checking the performance Schema output for the replication_group_member_stats table. |
| 61 |
|
| 62 |
--let $member_id= query_get_value(SELECT Member_Id from performance_schema.replication_group_member_stats, Member_Id, 1) |
| 63 |
--let $assert_text= The value of member_id should be empty before starting group replication |
| 64 |
--let $assert_cond= "$member_id" = "" |
| 65 |
--source include/assert.inc |
| 66 |
|
| 67 |
--let $view_id= query_get_value(SELECT View_Id from performance_schema.replication_group_member_stats, View_Id, 1) |
| 68 |
--let $assert_text= The value of view_id should be EMPTY before starting group replication |
| 69 |
--let $assert_cond= "$View_Id" = "" |
| 70 |
--source include/assert.inc |
| 71 |
|
| 72 |
--let $transaction_in_queue= query_get_value(SELECT Count_Transactions_in_queue from performance_schema.replication_group_member_stats, Count_Transactions_in_queue, 1) |
| 73 |
--let $assert_text= The value of Count_Transactions_in_queue should be 0 before starting group replication |
| 74 |
--let $assert_cond= "$transaction_in_queue" = 0 |
| 75 |
--source include/assert.inc |
| 76 |
|
| 77 |
--let $certified_transactions= query_get_value(SELECT Count_Transactions_checked from performance_schema.replication_group_member_stats, Count_Transactions_checked, 1) |
| 78 |
--let $assert_text= The value of Count_Transactions_checked should be 0 before starting group replication |
| 79 |
--let $assert_cond= "$certified_transactions" = 0 |
| 80 |
--source include/assert.inc |
| 81 |
|
| 82 |
--let $negatively_certified= query_get_value(SELECT Count_conflicts_detected from performance_schema.replication_group_member_stats, Count_conflicts_detected, 1) |
| 83 |
--let $assert_text= The value of Count_conflicts_detected should be 0 before starting group replication |
| 84 |
--let $assert_cond= "$negatively_certified" = 0 |
| 85 |
--source include/assert.inc |
| 86 |
|
| 87 |
--let $certification_db_size= query_get_value(SELECT Count_Transactions_rows_validating from performance_schema.replication_group_member_stats, Count_Transactions_rows_validating, 1) |
| 88 |
--let $assert_text= The value of Count_Transactions_rows_validating should be 0 before starting group replication |
| 89 |
--let $assert_cond= "$certification_db_size" = 0 |
| 90 |
--source include/assert.inc |
| 91 |
|
| 92 |
--let $stable_set= query_get_value(SELECT Transactions_Committed_all_members from performance_schema.replication_group_member_stats, Transactions_Committed_all_members, 1) |
| 93 |
--let $assert_text= The value of Transactions_Committed_all_members should be empty before starting group replication |
| 94 |
--let $assert_cond= "$stable_set" = 0 |
| 95 |
--source include/assert.inc |
| 96 |
|
| 97 |
--let $last_certified_transaction= query_get_value(SELECT Last_conflict_free_transaction from performance_schema.replication_group_member_stats, Last_conflict_free_transaction, 1) |
| 98 |
--let $assert_text= The value of Last_conflict_free_transaction should be 0 before starting group replication |
| 99 |
--let $assert_cond= "$last_certified_transaction" = "" |
| 100 |
--source include/assert.inc |
| 101 |
|
| 102 |
--echo ######################################################## |
| 103 |
--echo Values being updated after executing some transactions |
| 104 |
--echo ######################################################## |
| 105 |
|
| 106 |
# Start Group Replication |
| 107 |
--source include/start_and_bootstrap_group_replication.inc |
| 108 |
|
| 109 |
--let $raw_view_id= query_get_value(SELECT View_Id from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), View_Id, 1) |
| 110 |
--let $view_id= `SELECT RIGHT('$raw_view_id', 1)` |
| 111 |
--let $assert_text= The value of view_id should be a number followed by ONE at group replication start |
| 112 |
--let $assert_cond= "$View_Id" = 1 |
| 113 |
--source include/assert.inc |
| 114 |
|
| 115 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 116 |
INSERT INTO t1 VALUES (2); |
| 117 |
INSERT INTO t1 VALUES (3); |
| 118 |
INSERT INTO t1 values (4); |
| 119 |
|
| 120 |
# Block the applier on server 1 so that recovery blocks on server 2 |
| 121 |
# View_change_log_event will be written to the binary log after the |
| 122 |
# transactions aaa:1-2, since local transactions can still be |
| 123 |
# logged. Which means that server2 will receive both transactions |
| 124 |
# through recovery, and then through GCS on which will be rollback |
| 125 |
# (discarded after certification),thence the below suppressions. |
| 126 |
SET @@GLOBAL.DEBUG='+d,block_applier_updates'; |
| 127 |
|
| 128 |
--connection server2 |
| 129 |
--echo server2 |
| 130 |
|
| 131 |
SET SESSION sql_log_bin= 0; |
| 132 |
call mtr.add_suppression("The requested GTID 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1' was already used, the transaction will rollback"); |
| 133 |
SET SESSION sql_log_bin= 1; |
| 134 |
|
| 135 |
--let $group_replication_start_member_state= RECOVERING |
| 136 |
--source include/start_group_replication.inc |
| 137 |
|
| 138 |
--echo # Apply some transactions on the first member so that the queue of the second member is not empty. |
| 139 |
--connection server1 |
| 140 |
--echo server1 |
| 141 |
|
| 142 |
--connection server1_1 |
| 143 |
SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 144 |
--send INSERT INTO t1 VALUES (5) |
| 145 |
|
| 146 |
--echo # Check for the transaction in the applier queue and then unblock the recovery. |
| 147 |
--connection server2 |
| 148 |
--echo server2 |
| 149 |
|
| 150 |
--echo [ The value of Count_Transactions_in_queue must be 2 when the applier has not processed the transaction queue ] |
| 151 |
--let $wait_condition= SELECT Count_Transactions_in_queue = 2 from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid); |
| 152 |
--source include/wait_condition.inc |
| 153 |
|
| 154 |
--connection server1 |
| 155 |
--echo server1 |
| 156 |
|
| 157 |
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked"; |
| 158 |
SET @@GLOBAL.DEBUG='-d,block_applier_updates'; |
| 159 |
SET DEBUG_SYNC = "now SIGNAL resume_applier_read"; |
| 160 |
|
| 161 |
--connection server1_1 |
| 162 |
--reap |
| 163 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 164 |
|
| 165 |
--connection server2 |
| 166 |
--echo server2 |
| 167 |
|
| 168 |
--let $group_replication_member_state= ONLINE |
| 169 |
--source include/gr_wait_for_member_state.inc |
| 170 |
|
| 171 |
--connection server1 |
| 172 |
--echo server1 |
| 173 |
|
| 174 |
--let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 175 |
--let $member_id= query_get_value(SELECT Member_Id from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Member_Id, 1) |
| 176 |
--let $assert_text= The value of member_id should be equal to server UUID after starting group replication |
| 177 |
--let $assert_cond= "$member_id" = "$server_uuid" |
| 178 |
--source include/assert.inc |
| 179 |
|
| 180 |
--let $certified_transactions= query_get_value(SELECT Count_Transactions_checked from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Transactions_checked, 1) |
| 181 |
--let $assert_text= The value of Count_Transactions_checked should be 5 after starting group replication |
| 182 |
--let $assert_cond= "$certified_transactions" = 5 |
| 183 |
--source include/assert.inc |
| 184 |
|
| 185 |
--let $negatively_certified= query_get_value(SELECT Count_conflicts_detected from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_conflicts_detected, 1) |
| 186 |
--let $assert_text= The value of Count_conflicts_detected should be 0 after starting group replication |
| 187 |
--let $assert_cond= "$negatively_certified" = 0 |
| 188 |
--source include/assert.inc |
| 189 |
|
| 190 |
--let $certification_db_size= 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) |
| 191 |
--let $assert_text= The value of Count_Transactions_rows_validating should be 2 after starting group replication |
| 192 |
--let $assert_cond= "$certification_db_size" = 2 |
| 193 |
--source include/assert.inc |
| 194 |
|
| 195 |
--let $stable_set= 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) |
| 196 |
--let $assert_text= The value of Transactions_committed_all_members should have server 1 GTIDs before server2 start |
| 197 |
--let $assert_cond= "$stable_set" = "8a84f397-aaa4-18df-89ab-c70aa9823561:1-5" |
| 198 |
--source include/assert.inc |
| 199 |
|
| 200 |
--let $last_certified_transaction= query_get_value(SELECT Last_Conflict_free_transaction from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Last_Conflict_free_transaction, 1) |
| 201 |
--let $assert_text= The value of Last_Conflict_free_transaction should be the gtid of the last applied transaction. |
| 202 |
--let $assert_cond= "$last_certified_transaction" = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1" |
| 203 |
--source include/assert.inc |
| 204 |
|
| 205 |
SET SESSION sql_log_bin= 0; |
| 206 |
--source include/gtid_utils.inc |
| 207 |
SET SESSION sql_log_bin= 1; |
| 208 |
|
| 209 |
--echo [ The value of stable_set must be equal to the member GTID executed set ] |
| 210 |
--let $expected_gtid="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1,8a84f397-aaa4-18df-89ab-c70aa9823561:1-6" |
| 211 |
|
| 212 |
--let $_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 213 |
--let $wait_timeout= 150 |
| 214 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_group_member_stats WHERE Transactions_committed_all_members = "$_gtid_executed" and member_id in (SELECT @@server_uuid) |
| 215 |
--source include/wait_condition.inc |
| 216 |
|
| 217 |
--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) |
| 218 |
--let $assert_text= 'Transactions_committed_all_members must be equal to expected gtid value' |
| 219 |
--let $assert_cond= GTID_IS_EQUAL("$transactions_committed_all_members", $expected_gtid) |
| 220 |
--source include/assert.inc |
| 221 |
|
| 222 |
SET SESSION sql_log_bin= 0; |
| 223 |
--source include/gtid_utils_end.inc |
| 224 |
SET SESSION sql_log_bin= 1; |
| 225 |
|
| 226 |
--connection server1 |
| 227 |
--let $diff_tables=server1:t1, server2:t1 |
| 228 |
--source include/diff_tables.inc |
| 229 |
DROP TABLE t1; |
| 230 |
|
| 231 |
SET DEBUG_SYNC= 'RESET'; |
| 232 |
|
| 233 |
--echo #################################### |
| 234 |
--echo The values being checked after stop |
| 235 |
--echo #################################### |
| 236 |
|
| 237 |
# Stop Group Replication |
| 238 |
--source include/stop_group_replication.inc |
| 239 |
|
| 240 |
--connection server2 |
| 241 |
--source include/stop_group_replication.inc |
| 242 |
|
| 243 |
--disconnect server1_1 |
| 244 |
|
| 245 |
--source include/gr_clear_configuration.inc |