From a500865c133251416604255028802b550d6941a8 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Thu, 27 Mar 2014 16:22:57 -0400 Subject: [PATCH] Merged revision 3471, 3472 & 3473 from maria-5.5-galera. --- extra/my_print_defaults.c | 11 ++-- mysql-test/suite/galera/r/unique_key.result | 47 ++++++++++++++++ mysql-test/suite/galera/t/unique_key.test | 54 +++++++++++++++++++ .../suite/wsrep/r/pool_of_threads.result | 8 +++ mysql-test/suite/wsrep/t/pool_of_threads.opt | 1 + mysql-test/suite/wsrep/t/pool_of_threads.test | 11 ++++ sql/mysqld.cc | 5 ++ 7 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/galera/r/unique_key.result create mode 100644 mysql-test/suite/galera/t/unique_key.test create mode 100644 mysql-test/suite/wsrep/r/pool_of_threads.result create mode 100644 mysql-test/suite/wsrep/t/pool_of_threads.opt create mode 100644 mysql-test/suite/wsrep/t/pool_of_threads.test diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index e91163dde1c..bfd0c3c635a 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -98,6 +98,11 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; +void cleanup_and_exit(int exit_code) +{ + my_end(0); + exit(exit_code); +} static void usage(my_bool version) { @@ -112,7 +117,7 @@ static void usage(my_bool version) my_print_default_files(config_file); my_print_variables(my_long_options); printf("\nExample usage:\n%s --defaults-file=example.cnf client client-server mysql\n", my_progname); - exit(0); + cleanup_and_exit(0); } @@ -125,7 +130,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_defaults_file_used= 1; break; case 'n': - exit(0); + cleanup_and_exit(0); case 'I': case '?': usage(0); @@ -174,7 +179,7 @@ int main(int argc, char **argv) /* Check out the args */ if (get_options(&argc,&argv)) - exit(1); + cleanup_and_exit(1); nargs= argc + 1; if (opt_mysqld) diff --git a/mysql-test/suite/galera/r/unique_key.result b/mysql-test/suite/galera/r/unique_key.result new file mode 100644 index 00000000000..ffb4f01c1f8 --- /dev/null +++ b/mysql-test/suite/galera/r/unique_key.result @@ -0,0 +1,47 @@ +# +# MDEV#5552 Deadlock when inserting NULL column value in column with +# UNIQUE index +# +USE test; + +# On node_1 +CREATE TABLE t1(c1 INT DEFAULT NULL, UNIQUE KEY c1(c1)) ENGINE=INNODB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM test.t1; +c1 +NULL +NULL + +# On node_2 +SELECT * FROM test.t1; +c1 +NULL +NULL + +# On node_1 +INSERT INTO t1 VALUES (1); +UPDATE t1 SET c1=NULL WHERE c1=1; +SELECT * FROM test.t1; +c1 +NULL +NULL +NULL + +# On node_2 +SELECT * FROM test.t1; +c1 +NULL +NULL +NULL + +# On node_1 +DELETE FROM t1 WHERE c1<=>NULL; +SELECT * FROM test.t1; +c1 + +# On node_2 +SELECT * FROM test.t1; +c1 +DROP TABLE t1; +# End of test diff --git a/mysql-test/suite/galera/t/unique_key.test b/mysql-test/suite/galera/t/unique_key.test new file mode 100644 index 00000000000..00b85d57165 --- /dev/null +++ b/mysql-test/suite/galera/t/unique_key.test @@ -0,0 +1,54 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV#5552 Deadlock when inserting NULL column value in column with +--echo # UNIQUE index +--echo # + +USE test; +--echo +--echo # On node_1 +--connection node_1 +CREATE TABLE t1(c1 INT DEFAULT NULL, UNIQUE KEY c1(c1)) ENGINE=INNODB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM test.t1; + +--echo +--echo # On node_2 +--connection node_2 +SELECT * FROM test.t1; + + +--echo +--echo # On node_1 +--connection node_1 +INSERT INTO t1 VALUES (1); +UPDATE t1 SET c1=NULL WHERE c1=1; +SELECT * FROM test.t1; + +--echo +--echo # On node_2 +--connection node_2 +SELECT * FROM test.t1; + +--echo +--echo # On node_1 +--connection node_1 +DELETE FROM t1 WHERE c1<=>NULL; +SELECT * FROM test.t1; + +--echo +--echo # On node_2 +--connection node_2 +SELECT * FROM test.t1; + +--let $galera_diff_statement = SELECT * FROM t1 +--source include/galera_diff.inc + +# Cleanup +DROP TABLE t1; + +--source include/galera_end.inc +--echo # End of test diff --git a/mysql-test/suite/wsrep/r/pool_of_threads.result b/mysql-test/suite/wsrep/r/pool_of_threads.result new file mode 100644 index 00000000000..ffe309f2580 --- /dev/null +++ b/mysql-test/suite/wsrep/r/pool_of_threads.result @@ -0,0 +1,8 @@ + +# +# MDEV#5687: Maria doesn't shutdown following upgrade to 5.5.35-galera +# +SELECT @@GLOBAL.thread_handling; +@@GLOBAL.thread_handling +pool-of-threads +# End of test. diff --git a/mysql-test/suite/wsrep/t/pool_of_threads.opt b/mysql-test/suite/wsrep/t/pool_of_threads.opt new file mode 100644 index 00000000000..92994ddfb68 --- /dev/null +++ b/mysql-test/suite/wsrep/t/pool_of_threads.opt @@ -0,0 +1 @@ +--binlog-format=row --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=/usr/lib/galera/libgalera_smm.so --wsrep-cluster-address=gcomm:// --thread_handling=pool-of-threads diff --git a/mysql-test/suite/wsrep/t/pool_of_threads.test b/mysql-test/suite/wsrep/t/pool_of_threads.test new file mode 100644 index 00000000000..f4fffaf4f9a --- /dev/null +++ b/mysql-test/suite/wsrep/t/pool_of_threads.test @@ -0,0 +1,11 @@ +--source include/have_wsrep.inc + +--echo +--echo # +--echo # MDEV#5687: Maria doesn't shutdown following upgrade to 5.5.35-galera +--echo # + +# Note: This test is to ensure that server shuts down properly. +SELECT @@GLOBAL.thread_handling; + +--echo # End of test. diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e486630f390..0662afaa189 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2045,6 +2045,10 @@ extern "C" void unireg_abort(int exit_code) wsrep_close_threads(thd); /* this won't close all threads */ sleep(1); /* so give some time to exit for those which can */ WSREP_INFO("Some threads may fail to exit."); + + /* In bootstrap mode we deinitialize wsrep here. */ + if (opt_bootstrap && wsrep_inited) + wsrep_deinit(); } #endif // WITH_WSREP clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */ @@ -5323,6 +5327,7 @@ pthread_handler_t start_wsrep_THD(void *arg) // at server shutdown } + my_thread_end(); if (thread_handling > SCHEDULER_ONE_THREAD_PER_CONNECTION) { mysql_mutex_lock(&LOCK_thread_count);