| 1 |
--echo # |
| 2 |
--echo # Tests of the dedicated thread for refreshing the rules table. |
| 3 |
--echo # |
| 4 |
|
| 5 |
SET sql_mode = 'PIPES_AS_CONCAT'; |
| 6 |
|
| 7 |
--source include/have_debug_sync.inc |
| 8 |
--source suite/query_rewrite_plugins/include/have_plugin_rewriter.inc |
| 9 |
--source suite/query_rewrite_plugins/include/install_rewriter.inc |
| 10 |
|
| 11 |
--echo # |
| 12 |
--echo # We will now test shutting down the server while refreshing rules. We |
| 13 |
--echo # then restart the server and make sure it recovered. |
| 14 |
--echo # |
| 15 |
|
| 16 |
--echo # We will shut down the server while a session is waiting for a debug |
| 17 |
--echo # sync signal. All debug sync points are released during shutdown, |
| 18 |
--echo # so the plugin will proceed to try and read from a handler with a server |
| 19 |
--echo # that has gone away. This will lead to a storage engine error. |
| 20 |
CALL mtr.add_suppression( "Got error from storage engine while refreshing " || |
| 21 |
"rewrite rules." ); |
| 22 |
|
| 23 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 24 |
VALUES ( 'SELECT "Rewrite"', 'SELECT "Rewritten"' ); |
| 25 |
|
| 26 |
SET GLOBAL debug= '+d,dbug.block_do_refresh'; |
| 27 |
|
| 28 |
--connect (con1,localhost,root,,test,,) |
| 29 |
|
| 30 |
--echo # Two root connections are supposed to show here |
| 31 |
SELECT COUNT(user) FROM information_schema.processlist WHERE user LIKE 'root'; |
| 32 |
|
| 33 |
--echo # We have to do this in order to avoid deadlock on the memory table's |
| 34 |
--echo # mutex. |
| 35 |
SET @@global.rewriter_enabled = OFF; |
| 36 |
|
| 37 |
--send CALL query_rewrite.flush_rewrite_rules() |
| 38 |
|
| 39 |
--connection default |
| 40 |
|
| 41 |
--echo # We don't care if we time out here, as long as we manage to restart the |
| 42 |
--echo # server. |
| 43 |
--disable_warnings |
| 44 |
SET debug_sync = 'now WAIT_FOR parked'; |
| 45 |
--enable_warnings |
| 46 |
|
| 47 |
--echo # Two root connections are supposed to show here |
| 48 |
SELECT COUNT(user) FROM information_schema.processlist WHERE user LIKE 'root'; |
| 49 |
|
| 50 |
--echo # |
| 51 |
--echo # Restart the server |
| 52 |
--echo # |
| 53 |
|
| 54 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 55 |
--shutdown_server |
| 56 |
--source include/wait_until_disconnected.inc |
| 57 |
|
| 58 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 59 |
--enable_reconnect |
| 60 |
--source include/wait_until_connected_again.inc |
| 61 |
|
| 62 |
SELECT 'Rewrite'; |
| 63 |
|
| 64 |
--echo # One root connection is supposed to show here, as the rewrite thread is now gone |
| 65 |
SELECT COUNT(user) FROM information_schema.processlist WHERE user LIKE 'root'; |
| 66 |
|
| 67 |
SET @@global.rewriter_enabled = DEFAULT; |
| 68 |
--source suite/query_rewrite_plugins/include/uninstall_rewriter.inc |