MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
check_ftwrl_incompatible.inc
1 #
2 # SUMMARY
3 # Check that a statement is incompatible with FLUSH TABLES WITH READ LOCK.
4 #
5 # PARAMETERS
6 # $con_aux1 Name of the 1st aux connection to be used by this script.
7 # $con_aux2 Name of the 2nd aux connection to be used by this script.
8 # $statement The statement to be checked.
9 # $cleanup_stmt1 The 1st statement to be run in order to revert effects
10 # of statement to be checked.
11 # $cleanup_stmt2 The 2nd statement to be run in order to revert effects
12 # of statement to be checked.
13 # $skip_3rd_chk Skip the 3rd stage of checking. The purpose of the third
14 # stage is to check that metadata locks taken by this
15 # statement are incompatible with metadata locks taken
16 # by FTWRL.
17 #
18 # EXAMPLE
19 # flush_read_lock.test
20 #
21 --disable_result_log
22 --disable_query_log
23 
24 # Reset DEBUG_SYNC facility for safety.
25 set debug_sync= "RESET";
26 
27 #
28 # First, check that the statement cannot be run under FTWRL.
29 #
30 flush tables with read lock;
31 --disable_abort_on_error
32 --eval $statement
33 --enable_abort_on_error
34 let $err= $mysql_errno;
35 if ($err)
36 {
37 --echo Success: Was not able to run '$statement' under FTWRL.
38 unlock tables;
39 }
40 if (!$err)
41 {
42 --echo Error: Was able to run '$statement' under FTWRL!
43 unlock tables;
44 if ($cleanup_stmt1)
45 {
46 --eval $cleanup_stmt1;
47 }
48 if ($cleanup_stmt2)
49 {
50 --eval $cleanup_stmt2;
51 }
52 }
53 
54 
55 #
56 # Then check that this statement is blocked by FTWRL
57 # that is active in another connection.
58 #
59 connection $con_aux1;
60 flush tables with read lock;
61 
62 connection default;
63 --send_eval $statement;
64 
65 connection $con_aux1;
66 
67 --enable_result_log
68 --enable_query_log
69 let $wait_condition=
70  select count(*) = 1 from information_schema.processlist
71  where (state = "Waiting for global read lock" or
72  state = "Waiting for commit lock") and
73  info = "$statement";
74 --source include/wait_condition.inc
75 --disable_result_log
76 --disable_query_log
77 
78 if ($success)
79 {
80 --echo Success: '$statement' is blocked by FTWRL active in another connection.
81 }
82 if (!$success)
83 {
84 --echo Error: '$statement' wasn't blocked by FTWRL active in another connection!
85 }
86 unlock tables;
87 
88 connection default;
89 --reap
90 
91 if ($cleanup_stmt1)
92 {
93 --eval $cleanup_stmt1;
94 }
95 if ($cleanup_stmt2)
96 {
97 --eval $cleanup_stmt2;
98 }
99 
100 if (!$skip_3rd_check)
101 {
102 #
103 # Finally, let us check that FTWRL will not succeed if this
104 # statement is active but has already closed its tables.
105 #
106 connection default;
107 --eval set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
108 --send_eval $statement;
109 
110 connection $con_aux1;
111 set debug_sync="now WAIT_FOR parked";
112 --send flush tables with read lock
113 
114 connection $con_aux2;
115 --enable_result_log
116 --enable_query_log
117 let $wait_condition=
118  select count(*) = 1 from information_schema.processlist
119  where (state = "Waiting for global read lock" or
120  state = "Waiting for commit lock") and
121  info = "flush tables with read lock";
122 --source include/wait_condition.inc
123 --disable_result_log
124 --disable_query_log
125 
126 if ($success)
127 {
128 --echo Success: FTWRL is blocked when '$statement' is active in another connection.
129 }
130 if (!$success)
131 {
132 --echo Error: FTWRL isn't blocked when '$statement' is active in another connection!
133 }
134 set debug_sync="now SIGNAL go";
135 connection default;
136 --reap
137 connection $con_aux1;
138 --reap
139 unlock tables;
140 connection default;
141 
142 set debug_sync= "RESET";
143 
144 if ($cleanup_stmt1)
145 {
146 --eval $cleanup_stmt1;
147 }
148 if ($cleanup_stmt2)
149 {
150 --eval $cleanup_stmt2;
151 }
152 }
153 
154 --enable_result_log
155 --enable_query_log