|
| 1 | +# |
| 2 | +# SUMMARY |
| 3 | +# Check that a statement is compatible 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_stmt The statement to be run in order to revert effects of |
| 10 | +# the statement to be checked. |
| 11 | +# $skip_3rd_chk Skip the 3rd stage of checking. The purpose of the third |
| 12 | +# stage is to check that metadata locks taken by this |
| 13 | +# statement are compatible with metadata locks taken |
| 14 | +# by FTWRL. |
| 15 | +# |
| 16 | +# EXAMPLE |
| 17 | +# flush_read_lock.test |
| 18 | +# |
| 19 | +--disable_result_log |
| 20 | +--disable_query_log |
| 21 | + |
| 22 | +# Reset DEBUG_SYNC facility for safety. |
| 23 | +set debug_sync= "RESET"; |
| 24 | + |
| 25 | +# |
| 26 | +# First, check that the statement can be run under FTWRL. |
| 27 | +# |
| 28 | +flush tables with read lock; |
| 29 | +--disable_abort_on_error |
| 30 | +--eval $statement |
| 31 | +--enable_abort_on_error |
| 32 | +let $err= $mysql_errno; |
| 33 | +if (!$err) |
| 34 | +{ |
| 35 | +--echo Success: Was able to run '$statement' under FTWRL. |
| 36 | +unlock tables; |
| 37 | +if (`SELECT "$cleanup_stmt" <> ""`) |
| 38 | +{ |
| 39 | +--eval $cleanup_stmt; |
| 40 | +} |
| 41 | +} |
| 42 | +if ($err) |
| 43 | +{ |
| 44 | +--echo Error: Wasn't able to run '$statement' under FTWRL! |
| 45 | +unlock tables; |
| 46 | +} |
| 47 | +
|
| 48 | +# |
| 49 | +# Then check that this statement won't be blocked by FTWRL |
| 50 | +# that is active in another connection. |
| 51 | +# |
| 52 | +connection $con_aux1; |
| 53 | +flush tables with read lock; |
| 54 | + |
| 55 | +connection default; |
| 56 | +--send_eval $statement; |
| 57 | + |
| 58 | +connection $con_aux1; |
| 59 | + |
| 60 | +--enable_result_log |
| 61 | +--enable_query_log |
| 62 | +let $wait_condition= |
| 63 | + select count(*) = 0 from information_schema.processlist |
| 64 | + where info = "$statement"; |
| 65 | +--source include/wait_condition.inc |
| 66 | +--disable_result_log |
| 67 | +--disable_query_log |
| 68 | + |
| 69 | +if ($success) |
| 70 | +{ |
| 71 | +--echo Success: Was able to run '$statement' with FTWRL active in another connection. |
| 72 | + |
| 73 | +connection default; |
| 74 | +# Apparently statement was successfully executed and so |
| 75 | +# was not blocked by FTWRL. |
| 76 | +# To be safe against wait_condition.inc succeeding due to |
| 77 | +# races let us first reap the statement being checked to |
| 78 | +# ensure that it has been successfully executed. |
| 79 | +--reap |
| 80 | + |
| 81 | +connection $con_aux1; |
| 82 | +unlock tables; |
| 83 | + |
| 84 | +connection default; |
| 85 | +} |
| 86 | +if (!$success) |
| 87 | +{ |
| 88 | +--echo Error: Wasn't able to run '$statement' with FTWRL active in another connection! |
| 89 | +unlock tables; |
| 90 | +connection default; |
| 91 | +--reap |
| 92 | +} |
| 93 | +
|
| 94 | +if (`SELECT "$cleanup_stmt" <> ""`) |
| 95 | +{ |
| 96 | +--eval $cleanup_stmt; |
| 97 | +} |
| 98 | +
|
| 99 | +if (`SELECT "$skip_3rd_check" = ""`) |
| 100 | +{ |
| 101 | +# |
| 102 | +# Finally, let us check that FTWRL will succeed if this statement |
| 103 | +# is active but has already closed its tables. |
| 104 | +# |
| 105 | +connection default; |
| 106 | +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; |
| 107 | +--send_eval $statement; |
| 108 | +
|
| 109 | +connection $con_aux1; |
| 110 | +set debug_sync="now WAIT_FOR parked"; |
| 111 | +--send flush tables with read lock |
| 112 | +
|
| 113 | +connection $con_aux2; |
| 114 | +--enable_result_log |
| 115 | +--enable_query_log |
| 116 | +let $wait_condition= |
| 117 | + select count(*) = 0 from information_schema.processlist |
| 118 | + where info = "flush tables with read lock"; |
| 119 | +--source include/wait_condition.inc |
| 120 | +--disable_result_log |
| 121 | +--disable_query_log |
| 122 | +
|
| 123 | +if ($success) |
| 124 | +{ |
| 125 | +--echo Success: Was able to run FTWRL while '$statement' was active in another connection. |
| 126 | +connection $con_aux1; |
| 127 | +# Apparently FTWRL was successfully executed and so was not blocked by |
| 128 | +# the statement being checked. To be safe against wait_condition.inc |
| 129 | +# succeeding due to races let us first reap the FTWRL to ensure that it |
| 130 | +# has been successfully executed. |
| 131 | +--reap |
| 132 | +unlock tables; |
| 133 | +set debug_sync="now SIGNAL go"; |
| 134 | +connection default; |
| 135 | +--reap |
| 136 | +} |
| 137 | +if (!$success) |
| 138 | +{ |
| 139 | +--echo Error: Wasn't able to run FTWRL while '$statement' was active in another connection! |
| 140 | +set debug_sync="now SIGNAL go"; |
| 141 | +connection default; |
| 142 | +--reap |
| 143 | +connection $con_aux1; |
| 144 | +--reap |
| 145 | +unlock tables; |
| 146 | +connection default; |
| 147 | +} |
| 148 | + |
| 149 | +set debug_sync= "RESET"; |
| 150 | +if (`SELECT "$cleanup_stmt" <> ""`) |
| 151 | +{ |
| 152 | +--eval $cleanup_stmt; |
| 153 | +} |
| 154 | + |
| 155 | +} |
| 156 | + |
| 157 | +--enable_result_log |
| 158 | +--enable_query_log |
0 commit comments