|
| 1 | +include/group_replication.inc |
| 2 | +Warnings: |
| 3 | +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. |
| 4 | +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. |
| 5 | +[connection server1] |
| 6 | + |
| 7 | +# 1. Setup group of 2 servers, M1(primary) and M2(secondary). |
| 8 | +CREATE TABLE t1(c1 int primary key); |
| 9 | +include/start_and_bootstrap_group_replication.inc |
| 10 | +[connection server2] |
| 11 | +include/start_group_replication.inc |
| 12 | + |
| 13 | +# 2. Execute change primary from server2(secondary) and block the operation. |
| 14 | +[connection server2] |
| 15 | +SET @@GLOBAL.DEBUG= '+d,group_replication_block_primary_action_validation'; |
| 16 | +SELECT group_replication_set_as_primary("SERVER2_UUID", 1);; |
| 17 | +[connection server1] |
| 18 | + |
| 19 | +# 3. Execute transaction on server1(primary), transactions should fail. |
| 20 | +[connection server1] |
| 21 | +INSERT INTO t1 values(1); |
| 22 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 23 | +CREATE TABLE t2(c1 int primary key); |
| 24 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 25 | +CREATE TABLE t1(c1 int primary key); |
| 26 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 27 | +SELECT c1 FROM t1; |
| 28 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 29 | +DO group_replication_enable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION"); |
| 30 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 31 | +SELECT group_replication_enable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION"); |
| 32 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 33 | + |
| 34 | +# 4. Execute commands which are unaffected with |
| 35 | +# group_replication_set_as_primary() in execution. |
| 36 | +DO SLEEP(1); |
| 37 | +SELECT SLEEP(1); |
| 38 | +SLEEP(1) |
| 39 | +0 |
| 40 | +SELECT COUNT(*) from performance_schema.replication_group_members; |
| 41 | +COUNT(*) |
| 42 | +2 |
| 43 | +SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE='debug sync point: now'; |
| 44 | +COUNT(*)=0 |
| 45 | +1 |
| 46 | +SELECT COUNT(*)=1 FROM sys.version; |
| 47 | +COUNT(*)=1 |
| 48 | +1 |
| 49 | + |
| 50 | +# 5. Unblock change primary from server2 and reap the operation. |
| 51 | +[connection server_2] |
| 52 | +SET DEBUG_SYNC= "now SIGNAL signal.primary_action_continue"; |
| 53 | +[connection server2] |
| 54 | +group_replication_set_as_primary("SERVER2_UUID", 1) |
| 55 | +Primary server switched to: SERVER2_UUID |
| 56 | + |
| 57 | +# 6. Assert primary changed. |
| 58 | +# Assert data is not present on M1 and M2. |
| 59 | +[connection server2] |
| 60 | +include/gr_assert_primary_member.inc |
| 61 | +[connection server1] |
| 62 | +include/gr_assert_secondary_member.inc |
| 63 | +include/assert.inc ['There is no value 1 in table t1'] |
| 64 | +include/assert.inc ['Check table t2 does not exist.'] |
| 65 | +include/diff_tables.inc [server1:test.t1, server2:test.t1] |
| 66 | + |
| 67 | +# 7. Execute change primary from server2(primary) and block the operation. |
| 68 | +[connection server2] |
| 69 | +SELECT group_replication_set_as_primary("SERVER1_UUID", 1);; |
| 70 | +[connection server_2] |
| 71 | + |
| 72 | +# 8. Execute transaction on server2(primary), transactions should fail. |
| 73 | +[connection server_2] |
| 74 | +INSERT INTO t1 values(1); |
| 75 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 76 | +CREATE TABLE t2(c1 int primary key); |
| 77 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 78 | +CREATE TABLE t1(c1 int primary key); |
| 79 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 80 | +SELECT c1 FROM t1; |
| 81 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 82 | +DO group_replication_enable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION"); |
| 83 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 84 | +SELECT group_replication_enable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION"); |
| 85 | +ERROR HY000: All queries have been blocked while function 'group_replication_set_as_primary()' is executing. Please refer timeout parameter of function 'group_replication_set_as_primary()'. |
| 86 | + |
| 87 | +# 9. Execute commands which are not stopped. |
| 88 | +DO SLEEP(1); |
| 89 | +SELECT SLEEP(1); |
| 90 | +SLEEP(1) |
| 91 | +0 |
| 92 | +SELECT COUNT(*) from performance_schema.replication_group_members; |
| 93 | +COUNT(*) |
| 94 | +2 |
| 95 | +SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE='debug sync point: now'; |
| 96 | +COUNT(*)=0 |
| 97 | +1 |
| 98 | +SELECT COUNT(*)=1 FROM sys.version; |
| 99 | +COUNT(*)=1 |
| 100 | +1 |
| 101 | + |
| 102 | +# 10. Unblock change primary from server2 and reap the operation. |
| 103 | +SET DEBUG_SYNC= "now SIGNAL signal.primary_action_continue"; |
| 104 | +[connection server2] |
| 105 | +group_replication_set_as_primary("SERVER1_UUID", 1) |
| 106 | +Primary server switched to: SERVER1_UUID |
| 107 | + |
| 108 | +# 11. Assert primary changed. |
| 109 | +# Assert data is not present on M1 and M2. |
| 110 | +[connection server1] |
| 111 | +include/gr_assert_primary_member.inc |
| 112 | +[connection server2] |
| 113 | +include/gr_assert_secondary_member.inc |
| 114 | +include/assert.inc ['There is no value 1 in table t1'] |
| 115 | +include/assert.inc ['Check table t2 does not exist.'] |
| 116 | +include/diff_tables.inc [server1:test.t1, server2:test.t1] |
| 117 | + |
| 118 | +# 12. Cleanup. |
| 119 | +[connection server1] |
| 120 | +DROP TABLE t1; |
| 121 | +[connection server2] |
| 122 | +SET DEBUG_SYNC= 'RESET'; |
| 123 | +SET @@GLOBAL.DEBUG= '-d,group_replication_block_primary_action_validation'; |
| 124 | +include/group_replication_end.inc |
0 commit comments