From 581b49dd3d3e2e253812bb24fa881148675320b4 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 22 Apr 2015 18:13:30 -0400 Subject: [PATCH 01/15] MDEV-7995 : DMLs not getting replicated with log-bin=OFF & binlog-format != ROW This bug is a side-effect of fix for MDEV-6924, where we completely stopped a statement-based event from getting into the binlog cache when binary logging is not enabled (and thus, wsrep_emulate_binlog mode = 1). As a result, the SBR events were not replicated. Fixed by allowing the SBR events to be written into the binlog cache. Note: Only DMLs were affected as DDLs are replicated via TOI. Merged galera_create_trigger.test from github.com/codership/mysql-wsrep. --- mysql-test/suite/galera/r/galera_sbr.result | 14 +++++++++++ mysql-test/suite/galera/t/galera_sbr.test | 27 +++++++++++++++++++++ sql/log.cc | 18 +++++++++++++- sql/sql_class.cc | 10 -------- 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_sbr.result create mode 100644 mysql-test/suite/galera/t/galera_sbr.test diff --git a/mysql-test/suite/galera/r/galera_sbr.result b/mysql-test/suite/galera/r/galera_sbr.result new file mode 100644 index 00000000000..0bf6cc7c9d3 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sbr.result @@ -0,0 +1,14 @@ +SET SESSION binlog_format = 'STATEMENT'; +Warnings: +Warning 1105 MariaDB Galera does not support binlog format: STATEMENT +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION binlog_format = 'MIXED'; +Warnings: +Warning 1105 MariaDB Galera does not support binlog format: MIXED +INSERT INTO t1 VALUES (2); +SELECT COUNT(*) = 2 FROM t1; +COUNT(*) = 2 +1 +DROP TABLE t1; +SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/t/galera_sbr.test b/mysql-test/suite/galera/t/galera_sbr.test new file mode 100644 index 00000000000..33f45c6b532 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sbr.test @@ -0,0 +1,27 @@ +# +# Test behavior if the user attempts to use statement-based replication +# +# SBR is not currently supported but we expect that no crashes or binlog-related assertions will be triggered. +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +#SET GLOBAL binlog_format = 'STATEMENT'; +SET SESSION binlog_format = 'STATEMENT'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SET SESSION binlog_format = 'MIXED'; + +INSERT INTO t1 VALUES (2); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; + +--connection node_1 +SET GLOBAL binlog_format = 'ROW'; diff --git a/sql/log.cc b/sql/log.cc index d4403f4dfa4..8b2eb98c2e2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5167,7 +5167,19 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) binlog_cache_data *cache_data= 0; bool is_trans_cache= FALSE; bool using_trans= event_info->use_trans_cache(); - bool direct= event_info->use_direct_logging(); + bool direct; + +#ifdef WITH_WSREP + /* + When binary logging is not enabled (--log-bin=0), wsrep-patch partially + enables it without opening the binlog file (MSQL_BIN_LOG::open(). + So, avoid writing directly to binlog file. + */ + if (wsrep_emulate_bin_log) + direct= false; + else +#endif /* WITH_WSREP */ + direct= event_info->use_direct_logging(); if (thd->binlog_evt_union.do_union) { @@ -5948,6 +5960,10 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, DBUG_ENTER("MYSQL_BIN_LOG::write_transaction_to_binlog"); #ifdef WITH_WSREP + /* + Control should not be allowed beyond this point in wsrep_emulate_bin_log + mode. + */ if (wsrep_emulate_bin_log) DBUG_RETURN(0); #endif /* WITH_WSREP */ entry.thd= thd; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d40ca89a5ab..a55992bd0cf 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5885,16 +5885,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, The MYSQL_LOG::write() function will set the STMT_END_F flag and flush the pending rows event if necessary. */ -#ifdef WITH_WSREP - /* - Even though wsrep only supports ROW binary log format, a user can set - binlog format to STATEMENT (wsrep_forced_binlog_format). In which case - the control might reach here even when binary logging (--log-bin) is - not enabled. This is possible because wsrep patch partially enables - binary logging by setting wsrep_emulate_binlog. - */ - if (mysql_bin_log.is_open()) -#endif /* WITH_WSREP */ { Query_log_event qinfo(this, query_arg, query_len, is_trans, direct, suppress_use, errcode); From 51744b3f80a025a8c20c3aeb80741375a115d649 Mon Sep 17 00:00:00 2001 From: dirtysalt Date: Fri, 31 Oct 2014 15:55:18 +0800 Subject: [PATCH 02/15] Refs #8: [5.5] preserve gvwstate.dat for pc recovery feature --- scripts/wsrep_sst_xtrabackup-v2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 90892f9574f..d80af7454fb 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -282,7 +282,7 @@ read_cnf() progress=$(parse_cnf sst progress "") rebuild=$(parse_cnf sst rebuild 0) ttime=$(parse_cnf sst time 0) - cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') + cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*grastate\.dat$\|.*gvwstate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') incremental=$(parse_cnf sst incremental 0) ealgo=$(parse_cnf xtrabackup encrypt "") ekey=$(parse_cnf xtrabackup encrypt-key "") From 68fe3a39ac7f8c93b4c710b56403b9792b822c23 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Sun, 16 Nov 2014 16:26:36 +0200 Subject: [PATCH 03/15] refs #7 - handling lock queue granting in BF-BF conflict situation --- storage/innobase/lock/lock0lock.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 98cb239befc..b245e85ad1c 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -982,14 +982,15 @@ lock_rec_has_to_wait( } #ifdef WITH_WSREP - /* if BF thread is locking and has conflict with another BF + /* if BF thread has conflict with another BF thread, we need to look at trx ordering and lock types */ - if (for_locking && - wsrep_thd_is_BF(trx->mysql_thd, FALSE) && + if (wsrep_thd_is_BF(trx->mysql_thd, FALSE) && wsrep_thd_is_BF(lock2->trx->mysql_thd, TRUE)) { if (wsrep_debug) { - fprintf(stderr, "\n BF-BF lock conflict \n"); + fprintf(stderr, + "BF-BF lock conflict, locking: %d \n", + for_locking); lock_rec_print(stderr, lock2); } @@ -998,10 +999,17 @@ lock_rec_has_to_wait( (type_mode & LOCK_MODE_MASK) == LOCK_X && (lock2->type_mode & LOCK_MODE_MASK) == LOCK_X) { - /* exclusive lock conflicts are not accepted */ - fprintf(stderr, "BF-BF X lock conflict\n"); - lock_rec_print(stderr, lock2); - abort(); + if (for_locking) { + /* exclusive lock conflicts are not + accepted */ + fprintf(stderr, + "BF-BF X lock conflict\n"); + lock_rec_print(stderr, lock2); + abort(); + } else if (wsrep_debug) { + fprintf(stderr, + "BF-BF X lock conflict\n"); + } } else { /* if lock2->index->n_uniq <= lock2->index->n_user_defined_cols From 2a6e1230e3a709ac91ac299ec81a18fb37538e4b Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 30 Mar 2015 17:58:41 -0400 Subject: [PATCH 04/15] refs #7 - handling lock queue granting in BF-BF conflict situation Merge fix to xtradb. --- storage/xtradb/lock/lock0lock.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/storage/xtradb/lock/lock0lock.c b/storage/xtradb/lock/lock0lock.c index d9a5768d94c..1ac39a6fb26 100644 --- a/storage/xtradb/lock/lock0lock.c +++ b/storage/xtradb/lock/lock0lock.c @@ -983,14 +983,15 @@ lock_rec_has_to_wait( } #ifdef WITH_WSREP - /* if BF thread is locking and has conflict with another BF + /* if BF thread has conflict with another BF thread, we need to look at trx ordering and lock types */ - if (for_locking && - wsrep_thd_is_BF(trx->mysql_thd, FALSE) && + if (wsrep_thd_is_BF(trx->mysql_thd, FALSE) && wsrep_thd_is_BF(lock2->trx->mysql_thd, TRUE)) { if (wsrep_debug) { - fprintf(stderr, "\n BF-BF lock conflict \n"); + fprintf(stderr, + "BF-BF lock conflict, locking: %d \n", + for_locking); lock_rec_print(stderr, lock2); } @@ -999,10 +1000,17 @@ lock_rec_has_to_wait( (type_mode & LOCK_MODE_MASK) == LOCK_X && (lock2->type_mode & LOCK_MODE_MASK) == LOCK_X) { - /* exclusive lock conflicts are not accepted */ - fprintf(stderr, "BF-BF X lock conflict\n"); - lock_rec_print(stderr, lock2); - abort(); + if (for_locking) { + /* exclusive lock conflicts are not + accepted */ + fprintf(stderr, + "BF-BF X lock conflict\n"); + lock_rec_print(stderr, lock2); + abort(); + } else if (wsrep_debug) { + fprintf(stderr, + "BF-BF X lock conflict\n"); + } } else { /* if lock2->index->n_uniq <= lock2->index->n_user_defined_cols From 822c00536d461d56e81dd9c519ec5ec1cde9536a Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Tue, 9 Dec 2014 22:13:14 +0200 Subject: [PATCH 05/15] Going more MTR-friendly - for SST prefer to use mysql client, mysqldump and my_print_defaults from the local build tree. --- scripts/wsrep_sst_common.sh | 28 +++++++++++++++++++++++++++- scripts/wsrep_sst_mysqldump.sh | 8 ++++---- scripts/wsrep_sst_rsync.sh | 3 +-- scripts/wsrep_sst_xtrabackup-v2.sh | 10 +++++----- scripts/wsrep_sst_xtrabackup.sh | 10 +++++----- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index d9aa24169ce..2546074f7bd 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -88,8 +88,34 @@ shift done readonly WSREP_SST_OPT_BYPASS +# try to use my_print_defaults, mysql and mysqldump that come with the sources +# (for MTR suite) +SCRIPTS_DIR="$(cd $(dirname "$0"); pwd -P)" +EXTRA_DIR="$SCRIPTS_DIR/../extra" +CLIENT_DIR="$SCRIPTS_DIR/../client" + +if [ -x "$CLIENT_DIR/mysql" ]; then + MYSQL_CLIENT="$CLIENT_DIR/mysql" +else + MYSQL_CLIENT=$(which mysql) +fi + +if [ -x "$CLIENT_DIR/mysqldump" ]; then + MYSQLDUMP="$CLIENT_DIR/mysqldump" +else + MYSQLDUMP=$(which mysqldump) +fi + +if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then + MY_PRINT_DEFAULTS="$SCRIPTS_DIR/my_print_defaults" +elif [ -x "$EXTRA_DIR/my_print_defaults" ]; then + MY_PRINT_DEFAULTS="$EXTRA_DIR/my_print_defaults" +else + MY_PRINT_DEFAULTS=$(which my_print_defaults) +fi + # For Bug:1200727 -if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then +if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then if [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ];then WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2) fi diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index 3db1d73bb9c..53371765f66 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -54,9 +54,9 @@ then fi # Check client version -if ! mysql --version | grep 'Distrib 5.5' >/dev/null +if ! $MYSQL_CLIENT --version | grep 'Distrib 5.5' >/dev/null then - mysql --version >&2 + $MYSQL_CLIENT --version >&2 wsrep_log_error "this operation requires MySQL client version 5.5.x" exit $EINVAL fi @@ -72,7 +72,7 @@ if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi STOP_WSREP="SET wsrep_on=OFF;" # NOTE: we don't use --routines here because we're dumping mysql.proc table -MYSQLDUMP="mysqldump $AUTH -S$WSREP_SST_OPT_SOCKET \ +MYSQLDUMP="$MYSQLDUMP $AUTH -S$WSREP_SST_OPT_SOCKET \ --add-drop-database --add-drop-table --skip-add-locks --create-options \ --disable-keys --extended-insert --skip-lock-tables --quick --set-charset \ --skip-comments --flush-privileges --all-databases" @@ -97,7 +97,7 @@ DROP PREPARE stmt;" SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';" -MYSQL="mysql $AUTH -h$WSREP_SST_OPT_HOST -P$WSREP_SST_OPT_PORT "\ +MYSQL="$MYSQL_CLIENT $AUTH -h$WSREP_SST_OPT_HOST -P$WSREP_SST_OPT_PORT "\ "--disable-reconnect --connect_timeout=10" # need to disable logging when loading the dump diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 464b2b1ef3e..494ed4b5c02 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -83,8 +83,7 @@ WSREP_LOG_DIR=${WSREP_LOG_DIR:-""} # if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf if [ -z "$WSREP_LOG_DIR" ]; then - SCRIPT_DIR="$(cd $(dirname "$0"); pwd -P)" - WSREP_LOG_DIR=$($SCRIPT_DIR/my_print_defaults --defaults-file \ + WSREP_LOG_DIR=$($MY_PRINT_DEFAULTS --defaults-file \ "$WSREP_SST_OPT_CONF" mysqld server mysqld-5.5 mariadb mariadb-5.5 \ | grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \ | cut -b 29- ) diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index d80af7454fb..1a191a6ad6b 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -117,7 +117,7 @@ get_keys() fi if [[ $encrypt -eq 0 ]];then - if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html " fi return @@ -230,7 +230,7 @@ parse_cnf() { local group=$1 local var=$2 - reval=$(my_print_defaults -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-) + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-) if [[ -z $reval ]];then [[ -n $3 ]] && reval=$3 fi @@ -241,7 +241,7 @@ get_footprint() { pushd $WSREP_SST_OPT_DATA 1>/dev/null payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }') - if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then # QuickLZ has around 50% compression ratio # When compression/compaction used, the progress is only an approximate. payload=$(( payload*1/2 )) @@ -443,8 +443,8 @@ check_extra() { local use_socket=1 if [[ $uextra -eq 1 ]];then - if my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then - local eport=$(my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then + local eport=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) if [[ -n $eport ]];then # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh index dd4060e6961..044f9995580 100644 --- a/scripts/wsrep_sst_xtrabackup.sh +++ b/scripts/wsrep_sst_xtrabackup.sh @@ -100,7 +100,7 @@ get_keys() fi if [[ $encrypt -eq 0 ]];then - if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html " fi return @@ -195,7 +195,7 @@ parse_cnf() { local group=$1 local var=$2 - reval=$(my_print_defaults -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-) + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-) if [[ -z $reval ]];then [[ -n $3 ]] && reval=$3 fi @@ -206,7 +206,7 @@ get_footprint() { pushd $WSREP_SST_OPT_DATA 1>/dev/null payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }') - if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then # QuickLZ has around 50% compression ratio # When compression/compaction used, the progress is only an approximate. payload=$(( payload*1/2 )) @@ -385,8 +385,8 @@ check_extra() { local use_socket=1 if [[ $uextra -eq 1 ]];then - if my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then - local eport=$(my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then + local eport=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) if [[ -n $eport ]];then # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. From c72ed05cdc215c14e41d0466a3d50d2c1a3a2033 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Wed, 10 Dec 2014 01:45:50 +0200 Subject: [PATCH 06/15] This commit * improves MySQL client version check making it no less than required as opposed to exactly as required. * adds event table copying to ensure same results as with rsync SST. --- scripts/wsrep_sst_mysqldump.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index 53371765f66..e21e1cd01bc 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -54,7 +54,8 @@ then fi # Check client version -if ! $MYSQL_CLIENT --version | grep 'Distrib 5.5' >/dev/null +CLIENT_MINOR=$(mysql --version | cut -d ' ' -f 6 | cut -d '.' -f 2) +if [ $CLIENT_MINOR -lt "5" ] then $MYSQL_CLIENT --version >&2 wsrep_log_error "this operation requires MySQL client version 5.5.x" @@ -75,7 +76,7 @@ STOP_WSREP="SET wsrep_on=OFF;" MYSQLDUMP="$MYSQLDUMP $AUTH -S$WSREP_SST_OPT_SOCKET \ --add-drop-database --add-drop-table --skip-add-locks --create-options \ --disable-keys --extended-insert --skip-lock-tables --quick --set-charset \ ---skip-comments --flush-privileges --all-databases" +--skip-comments --flush-privileges --all-databases --events" # mysqldump cannot restore CSV tables, fix this issue CSV_TABLES_FIX=" From b02d73656000107250b288c77668ce671fdacb10 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Wed, 10 Dec 2014 23:29:28 +0200 Subject: [PATCH 07/15] Refs #25 - made sure signals that may be set to ignored in mysqld were set to default in the child process. --- sql/wsrep_utils.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 099e6403dd6..ee87b9615a8 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -150,7 +150,35 @@ process::process (const char* cmd, const char* type) goto cleanup_pipe; } - err_ = posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSIGDEF | + /* make sure that no signlas are masked in child process */ + sigset_t sigmask_empty; sigemptyset(&sigmask_empty); + err_ = posix_spawnattr_setsigmask(&attr, &sigmask_empty); + if (err_) + { + WSREP_ERROR ("posix_spawnattr_setsigmask() failed: %d (%s)", + err_, strerror(err_)); + goto cleanup_attr; + } + + /* make sure the following signals are not ignored in child process */ + sigset_t default_signals; sigemptyset(&default_signals); + sigaddset(&default_signals, SIGHUP); + sigaddset(&default_signals, SIGINT); + sigaddset(&default_signals, SIGQUIT); + sigaddset(&default_signals, SIGPIPE); + sigaddset(&default_signals, SIGTERM); + sigaddset(&default_signals, SIGCHLD); + err_ = posix_spawnattr_setsigdefault(&attr, &default_signals); + if (err_) + { + WSREP_ERROR ("posix_spawnattr_setsigdefault() failed: %d (%s)", + err_, strerror(err_)); + goto cleanup_attr; + } + + err_ = posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSIGDEF | + POSIX_SPAWN_SETSIGMASK | + /* start a new process group */ POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_USEVFORK); if (err_) { From f6b1e0fe0a33c724839abab74ae07bbbd41a23e6 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 5 Feb 2015 14:38:03 +0200 Subject: [PATCH 08/15] refs #55 fixed debug build compilation errors --- storage/innobase/lock/lock0lock.c | 2 +- storage/xtradb/lock/lock0lock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index b245e85ad1c..07e12cd43f6 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -989,7 +989,7 @@ lock_rec_has_to_wait( if (wsrep_debug) { fprintf(stderr, - "BF-BF lock conflict, locking: %d \n", + "BF-BF lock conflict, locking: %lu \n", for_locking); lock_rec_print(stderr, lock2); } diff --git a/storage/xtradb/lock/lock0lock.c b/storage/xtradb/lock/lock0lock.c index 1ac39a6fb26..e36829daed6 100644 --- a/storage/xtradb/lock/lock0lock.c +++ b/storage/xtradb/lock/lock0lock.c @@ -990,7 +990,7 @@ lock_rec_has_to_wait( if (wsrep_debug) { fprintf(stderr, - "BF-BF lock conflict, locking: %d \n", + "BF-BF lock conflict, locking: %lu \n", for_locking); lock_rec_print(stderr, lock2); } From 70d6236afd55b74211fee507c5af6b2b631c3f26 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 10 Feb 2015 00:47:02 +0200 Subject: [PATCH 09/15] refs codership/mysql-wsrep#55 - To avoid compiler warming: sql/sql_parse.cc: In function 'bool do_command(THD*)': sql/sql_parse.cc:758:20: error: 'packet_length' may be used uninitialized in this function [-Werror=maybe-uninitialized] if ((WSREP(thd) && packet_length == packet_error) || [ --- sql/sql_parse.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 991f960b2c4..c931a02661e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -693,7 +693,11 @@ bool do_command(THD *thd) { bool return_value; char *packet= 0; +#ifdef WITH_WSREP + ulong packet_length= 0; // just to avoid (false positive) compiler warning +#else ulong packet_length; +#endif /* WITH_WSREP */ NET *net= &thd->net; enum enum_server_command command; DBUG_ENTER("do_command"); From f3efc63283a232bfe3dc74d45a7ca4a3fcc683c8 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Tue, 10 Feb 2015 18:27:21 +0200 Subject: [PATCH 10/15] refs codership/mysql-wsrep#60 explicit braces around empty body --- sql/wsrep_var.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index ba92c6a4773..66b33e7697c 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -570,7 +570,9 @@ static void export_wsrep_status_to_mysql(THD* thd) for (wsrep_status_len = 0; thd->wsrep_status_vars[wsrep_status_len].name != NULL; - wsrep_status_len++); + wsrep_status_len++) { + /* */ + } #if DYNAMIC if (wsrep_status_len != mysql_status_len) { From 42f99d00eee0023184c6d985fa6f4e7a9717c3d8 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 18 Mar 2015 21:17:31 +0200 Subject: [PATCH 11/15] codership/mysql-wsrep#67 - total order isolation for FLUSH The following FLUSH commands are now executed under total order isolation: * FLUSH DES_KEY_FILE * FLUSH HOSTS * FLUSH PRIVILEGES * FLUSH QUERY CACHE * FLUSH STATUS * FLUSH USER_RESOURCES This patch was backported from mysql-wsrep/5.6 commit cdea608d9a27701d76d0deec49976aa0a08b1a56 --- sql/sql_parse.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c931a02661e..1b965b080e0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4119,6 +4119,21 @@ end_with_restore_list: break; } +#ifdef WITH_WSREP + if (lex->type & ( + REFRESH_GRANT | + REFRESH_HOSTS | + REFRESH_DES_KEY_FILE | +#ifdef HAVE_QUERY_CACHE + REFRESH_QUERY_CACHE_FREE | +#endif /* HAVE_QUERY_CACHE */ + REFRESH_STATUS | + REFRESH_USER_RESOURCES)) + { + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) + } +#endif /* WITH_WSREP*/ + /* reload_acl_and_cache() will tell us if we are allowed to write to the binlog or not. From e1868fd61335129d648794389258de2ac021eb91 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 7 May 2015 22:18:34 +0200 Subject: [PATCH 12/15] MDEV-8115 mysql_upgrade crashes the server with REPAIR VIEW on REPAIR don't do table-specific stuff for views (because even if the view has a temp table opened for it, it's not opened all the way down the engine. In particular, Aria crashes in maria_status() because MARIA_HA* info - that is table->table->file->file - is NULL) --- mysql-test/r/repair.result | 7 +++++++ mysql-test/t/repair.test | 9 +++++++++ sql/sql_admin.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 52ae9c38792..51c3374602d 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -207,3 +207,10 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +create table t1 (a blob); +create view v1 as select * from t1; +repair view v1; +Table Op Msg_type Msg_text +test.v1 repair status OK +drop view v1; +drop table t1; diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 337b73f37d1..f625965090a 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -208,3 +208,12 @@ repair table t1 use_frm; select count(*) from t1; check table t1; drop table t1; + +# +# MDEV-8115 mysql_upgrade crashes the server with REPAIR VIEW +# +create table t1 (a blob); +create view v1 as select * from t1; +repair view v1; +drop view v1; +drop table t1; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 6c50a221c90..8909e5ae05d 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -901,7 +901,7 @@ send_result_message: break; } } - if (table->table) + if (table->table && !table->view) { if (table->table->s->tmp_table) { From 048039e0b2052cec0b72e6a442ef73e6b118437a Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 11 May 2015 15:42:20 -0400 Subject: [PATCH 13/15] Fix for build failure. --- sql/sql_view.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 47b238715ac..f40053f6b49 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -858,7 +858,7 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, view->db, view->table_name); DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); } - sql_print_information("View %`s.%`s: the version is set to %llu%s%s", + sql_print_information("View %s.%s: the version is set to %llu%s%s", view->db, view->table_name, view->mariadb_version, (wrong_checksum ? ", checksum corrected" : ""), (swap_alg ? From 18fee8b8f8b7cdf3d58075c9734e9ace23e2dbec Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 12 May 2015 17:05:41 -0400 Subject: [PATCH 14/15] Revert last commit. --- sql/sql_view.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f40053f6b49..47b238715ac 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -858,7 +858,7 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, view->db, view->table_name); DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); } - sql_print_information("View %s.%s: the version is set to %llu%s%s", + sql_print_information("View %`s.%`s: the version is set to %llu%s%s", view->db, view->table_name, view->mariadb_version, (wrong_checksum ? ", checksum corrected" : ""), (swap_alg ? From 014fe12c03a2fdcbd2eb6bab39118de1cee02693 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 12 May 2015 14:19:30 -0400 Subject: [PATCH 15/15] Fix for debug build failure Do not use format function attribute for sql_print_xxx() family of functions as they use a MariaDB-specific extension of printf instead of one provided by the system. --- sql/log.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sql/log.h b/sql/log.h index ed33ace7405..4abefc55b90 100644 --- a/sql/log.h +++ b/sql/log.h @@ -881,11 +881,9 @@ uint purge_log_get_error_code(int res); int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); void sql_print_error(const char *format, ...); -void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void sql_print_information(const char *format, ...) - ATTRIBUTE_FORMAT(printf, 1, 2); -typedef void (*sql_print_message_func)(const char *format, ...) - ATTRIBUTE_FORMAT_FPTR(printf, 1, 2); +void sql_print_warning(const char *format, ...); +void sql_print_information(const char *format, ...); +typedef void (*sql_print_message_func)(const char *format, ...); extern sql_print_message_func sql_print_message_handlers[]; int error_log_print(enum loglevel level, const char *format,