diff options
author | unknown <sasha@mysql.sashanet.com> | 2002-01-24 22:49:47 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2002-01-24 22:49:47 -0700 |
commit | de172721edc0d619f12ea9769373fa0d7fcfbeb5 (patch) | |
tree | dbd006cf3d35d4daf9ae21af895de3a3261faf0b /client/mysqltest.c | |
parent | 1c2802931e0ac2c328d5a0caa8955e774048bbb3 (diff) | |
download | mariadb-git-de172721edc0d619f12ea9769373fa0d7fcfbeb5.tar.gz |
more predicatable slave behaviour with wait_for_slave_stop in mysqltest
fixed a couple of bugs with SEQ_READ_APPEND cache
rpl000016 still has non-deterministic result, but I am going to commit and
push since what I have is now better than what is in the main repository
client/mysqltest.c:
added wait_for_slave_to_stop
cleaned up TODO and comments
include/my_sys.h:
fixed race in flush_io_cache in SEQ_READ_APPEND cache
mysql-test/r/rpl000016.result:
updated result
mysql-test/t/rpl000016.test:
use wait_for_slave_to_stop to have deterministic slave behaviour for the test
mysys/mf_iocache.c:
fixed race in flush_io_cache()
fixed failure to unlock mutex in my_b_append()
sql/log.cc:
be compatible with 3.23 master
sql/log_event.cc:
3.23 master compat
sql/slave.cc:
3.23 master compat
sql/sql_class.h:
compat with 3.23 master
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r-- | client/mysqltest.c | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 762589b0374..510fe6a3f4c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -15,7 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* mysqltest test tool - * See man page for more information. + * See the manual for more information + * TODO: document better how mysqltest works * * Written by: * Sasha Pachev <sasha@mysql.com> @@ -26,9 +27,6 @@ /********************************************************************** TODO: -- Print also the queries that returns a result to the log file; This makes - it much easier to find out what's wrong. - - Do comparison line by line, instead of doing a full comparison of the text file. This will save space as we don't need to keep many results in memory. It will also make it possible to do simple @@ -43,7 +41,7 @@ **********************************************************************/ -#define MTEST_VERSION "1.13" +#define MTEST_VERSION "1.14" #include <my_global.h> #include <mysql_embed.h> @@ -88,6 +86,12 @@ #define CON_RETRY_SLEEP 2 #define MAX_CON_TRIES 5 +#ifndef OS2 +#define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */ +#else +#defile SLAVE_POLL_INTERVAL 0.3 +#endif + enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT}; @@ -187,6 +191,7 @@ Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT, Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER, +Q_WAIT_FOR_SLAVE_TO_STOP, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ Q_COMMENT_WITH_COMMAND @@ -222,7 +227,7 @@ const char *command_names[] = { "enable_query_log", "disable_query_log", "enable_result_log", "disable_result_log", "server_start", "server_stop", - "require_manager", + "require_manager", "wait_for_slave_to_stop", 0 }; @@ -653,6 +658,45 @@ int open_file(const char* name) return 0; } +/* ugly long name, but we are following the convention */ +int do_wait_for_slave_to_stop(struct st_query* __attribute__((unused)) q) +{ + MYSQL* mysql = &cur_con->mysql; +#ifndef OS2 + struct timeval t; +#endif + for (;;) + { + MYSQL_RES* res; + MYSQL_ROW row; + int done; + LINT_INIT(res); + + if (mysql_query(mysql,"show status like 'Slave_running'") + || !(res=mysql_store_result(mysql))) + die("Query failed while probing slave for stop: %s", + mysql_error(mysql)); + if (!(row=mysql_fetch_row(res)) || !row[1]) + { + mysql_free_result(res); + die("Strange result from query while probing slave for stop"); + } + done = !strcmp(row[1],"OFF"); + mysql_free_result(res); + if (done) + break; +#ifndef OS2 + t.tv_sec=0; + t.tv_usec=SLAVE_POLL_INTERVAL; + select(0,0,0,0,&t); /* sleep */ +#else + DosSleep(OS2_SLAVE_POLL_INTERVAL); +#endif + } + + return 0; +} + int do_require_manager(struct st_query* __attribute__((unused)) q) { if (!manager) @@ -2335,6 +2379,7 @@ int main(int argc, char** argv) case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_SOURCE: do_source(q); break; case Q_SLEEP: do_sleep(q); break; + case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break; case Q_REQUIRE_MANAGER: do_require_manager(q); break; #ifndef EMBEDDED_LIBRARY case Q_SERVER_START: do_server_start(q); break; |