|
| 1 | +--source include/have_mysqld_safe.inc |
| 2 | +--source include/not_windows.inc |
| 3 | + |
| 4 | + |
| 5 | +# Ensure when RESTART when mysqld is managed with no SUPERVISOR returns error. |
| 6 | +--error ER_RESTART_SERVER_FAILED |
| 7 | +RESTART; |
| 8 | + |
| 9 | +--echo # Verifying RESTART using mysqld_safe as supervisor process. |
| 10 | + |
| 11 | +# 1) Set valiables to be used in parameters of mysqld_safe. |
| 12 | +let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 13 | +let $MYSQL_BASEDIR= `SELECT @@basedir`; |
| 14 | +let $MYSQL_SOCKET= `SELECT @@socket`; |
| 15 | +let $MYSQL_TIMEZONE= `SELECT @@time_zone`; |
| 16 | +let $MYSQL_PIDFILE= `SELECT @@pid_file`; |
| 17 | +let $MYSQL_PORT= `SELECT @@port`; |
| 18 | +let $MYSQL_MESSAGESDIR= `SELECT @@lc_messages_dir`; |
| 19 | +let $start_page_size= `select @@innodb_page_size`; |
| 20 | +let $other_page_size_k= `SELECT $start_page_size DIV 1024`; |
| 21 | +let $other_page_size_nk= `SELECT CONCAT($other_page_size_k,'k')`; |
| 22 | + |
| 23 | +# mysqld_path to be passed to --ledir |
| 24 | +# use test; |
| 25 | +perl; |
| 26 | + my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 27 | + open ( OUTPUT, ">$dir/tmp/mysqld_path_file.inc") ; |
| 28 | + my $path = $ENV{MYSQLD}; |
| 29 | + $path =~ /^(.*)\/([^\/]*)$/; |
| 30 | + print OUTPUT "let \$mysqld_path = $1;\n"; |
| 31 | + print OUTPUT "let \$mysqld_bin = $2;\n"; |
| 32 | + close (OUTPUT); |
| 33 | +EOF |
| 34 | + |
| 35 | +#Get the value of the variable from to MTR, from perl |
| 36 | +--source $MYSQLTEST_VARDIR/tmp/mysqld_path_file.inc |
| 37 | + |
| 38 | +#Remove the temp file |
| 39 | +--remove_file $MYSQLTEST_VARDIR/tmp/mysqld_path_file.inc |
| 40 | + |
| 41 | +# 2) Shutdown mysqld which is started by mtr. |
| 42 | +--let $_server_id= `SELECT @@server_id` |
| 43 | +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect |
| 44 | +--exec echo "wait" > $_expect_file_name |
| 45 | +--shutdown_server |
| 46 | +--source include/wait_until_disconnected.inc |
| 47 | + |
| 48 | +# 3) Run the mysqld_safe script with exec. |
| 49 | +--exec sh $MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR --ledir=$mysqld_path --mysqld=$mysqld_bin --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET --pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=SYSTEM --log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --secure-file-priv="" --loose-skip-log-bin --core-file --lc-messages-dir=$MYSQL_MESSAGESDIR --innodb-page-size=$other_page_size_nk < /dev/null > /dev/null 2>&1 & |
| 50 | +# mysqld_safe takes some time to start mysqld |
| 51 | +--enable_reconnect |
| 52 | +--source include/wait_until_connected_again.inc |
| 53 | +--disable_reconnect |
| 54 | + |
| 55 | +# 4) Reconnect to mysqld again |
| 56 | +connection default; |
| 57 | + |
| 58 | +# 5) Execute the RESTART sql command. |
| 59 | +--exec $MYSQL -h localhost -S $MYSQL_SOCKET -P $MYSQL_PORT -u root -e "RESTART" 2>&1 |
| 60 | +--source include/wait_until_disconnected.inc |
| 61 | +# mysqld_safe takes some time to restart mysqld |
| 62 | +--enable_reconnect |
| 63 | +--source include/wait_until_connected_again.inc |
| 64 | +--echo # Executing a sql command after RESTART. |
| 65 | +SELECT 1; |
| 66 | + |
| 67 | +# 5.1) Create user and GRANT shutdown privilege on the user, execute RESTART. |
| 68 | +# First check check user can't execute RESTART without SHUTDOWN privilege. |
| 69 | +CREATE USER u1@localhost; |
| 70 | +GRANT SHUTDOWN ON *.* TO u1@localhost; |
| 71 | +--connect(con1,localhost,u1,'',,) |
| 72 | +RESTART; |
| 73 | +--source include/wait_until_disconnected.inc |
| 74 | +--enable_reconnect |
| 75 | +--source include/wait_until_connected_again.inc |
| 76 | +--connect(root_con,localhost,root,'',,) |
| 77 | +REVOKE SHUTDOWN ON *.* FROM u1@localhost; |
| 78 | +FLUSH PRIVILEGES; |
| 79 | +disconnect con1; |
| 80 | +--connect(con1,localhost,u1,'',,) |
| 81 | +--error ER_SPECIFIC_ACCESS_DENIED_ERROR |
| 82 | +RESTART; |
| 83 | +--connection root_con |
| 84 | +DROP USER u1@localhost; |
| 85 | +--disable_reconnect |
| 86 | + |
| 87 | +# 7) Shutdown mysqld with mysqladmin |
| 88 | +--exec $MYSQLADMIN -h localhost -S $MYSQL_SOCKET -P $MYSQL_PORT -u root shutdown 2>&1 |
| 89 | + |
| 90 | +# Delay introduced - mysqld_safe takes some time to restart mysqld |
| 91 | +--source include/wait_until_disconnected.inc |
| 92 | + |
| 93 | +# 8) Restart mysqld of mtr |
| 94 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 95 | +--enable_reconnect |
| 96 | +--source include/wait_until_connected_again.inc |
0 commit comments