Debian Codegraph @

mysql-test/suite/group_replication/include/gr_parallel_command_primary_change.inc

raw
1 # ==== Purpose ====
2 #
3 # Check commands run successfully with change of primary operation.
4 # This file may not be used for multi-statements or explicit commands like
5 # START TRANSACTION;
6 # ==== Usage ====
7 #
8 # --let $conn_of_new_primary= CLIENT_CONNECTION
9 # --let $command_to_execute= COMMAND
10 # --let $conn_for_command= CLIENT_CONNECTION
11 # --let $conn_for_debug_sync= CLIENT_CONNECTION
12 # --let $conn_for_primary= CLIENT_CONNECTION
13 # [--let $connection_is_killed= 1]
14 # --source ../include/gr_parallel_command_primary_change.inc
15 #
16 # Parameters:
17 #
18 # $conn_of_new_primary
19 # Connection of member which is to be selected as primary.
20 # Required to fetch SERVER_UUID.
21 #
22 # $command_to_execute
23 # Command to run before running UDF group_replication_set_as_primary.
24 # Command will be blocked post which UDF will execute.
25 #
26 # $conn_for_command
27 # Connection on which to execute the command.
28 #
29 # $conn_for_debug_sync
30 # Connection on which DEBUG_SYNC should be executed.
31 #
32 # $conn_for_primary
33 # Connection on which UDF group_replication_set_as_primary should be
34 # executed.
35 #
36 # $connection_is_killed
37 # Set to 1, if connection will be killed by UDF.
38
39 if (!$conn_of_new_primary)
40 {
41 --die "Missing parameter 'conn_of_new_primary'"
42 }
43
44 if (!$command_to_execute)
45 {
46 --die "Missing parameter 'command_to_execute'"
47 }
48
49 if (!$conn_for_command)
50 {
51 --die "Missing parameter 'conn_for_command'"
52 }
53
54 if (!$conn_for_debug_sync)
55 {
56 --die "Missing parameter 'conn_for_debug_sync'"
57 }
58
59 if (!$conn_for_primary)
60 {
61 --die "Missing parameter 'conn_for_primary'"
62 }
63
64 --let $_saved_connection= $CURRENT_CONNECTION
65
66 --let $rpl_connection_name= $conn_of_new_primary
67 --source include/rpl_connection.inc
68 --let $uuid_of_new_primary= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
69
70 --echo
71 --echo # Start a transaction on $conn_for_command and block it.
72
73 --let $rpl_connection_name= $conn_for_command
74 --source include/rpl_connection.inc
75
76 SET DEBUG_SYNC="before_reset_query_plan SIGNAL before_reset_query_ongoing WAIT_FOR after_reset_query_finished";
77
78 --send_eval $command_to_execute;
79
80 --let $rpl_connection_name= $conn_for_debug_sync
81 --source include/rpl_connection.inc
82
83 SET DEBUG_SYNC="now WAIT_FOR before_reset_query_ongoing";
84
85 --echo
86 --echo # Begin change of primary on $conn_for_primary.
87
88 --let $rpl_connection_name= $conn_for_primary
89 --source include/rpl_connection.inc
90
91 --replace_result $uuid_of_new_primary MEMBER_UUID
92 --eval SELECT group_replication_set_as_primary("$uuid_of_new_primary", 1)
93
94 --echo
95 --echo # Assert primary changed.
96
97 --let $rpl_connection_name= $conn_of_new_primary
98 --source include/rpl_connection.inc
99
100 --source include/gr_assert_primary_member.inc
101
102 --echo
103 --echo # Reap the transaction.
104
105 --let $rpl_connection_name= $conn_for_debug_sync
106 --source include/rpl_connection.inc
107 # before_reset_query_plan is present at 2 places so for safety added 2 signals
108 SET DEBUG_SYNC="now SIGNAL after_reset_query_finished";
109 SET DEBUG_SYNC="now SIGNAL after_reset_query_finished";
110
111 --let $rpl_connection_name= $conn_for_command
112 --source include/rpl_connection.inc
113
114 if ($connection_is_killed)
115 {
116 --error CR_SERVER_LOST
117 --reap
118
119 --enable_reconnect
120 --source include/wait_until_connected_again.inc
121 --disable_reconnect
122 }
123 if (!$connection_is_killed)
124 {
125 --reap
126 }
127 SET DEBUG_SYNC="RESET";
128
129 --connection $_saved_connection
130 --let $uuid_of_new_primary=
131 --let $conn_of_new_primary=
132 --let $command_to_execute=
133 --let $conn_for_command=
134 --let $conn_for_debug_sync=
135 --let $conn_for_primary=
136 --let $connection_is_killed=
137 --let $_saved_connection=