From 7dc51833172d4d0a2e7f218a1fa6380d5bee35fe Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 2 Jan 2018 13:40:05 +1100 Subject: [PATCH 01/13] wsrep_sst_rsync: read correct configuration sections 4bb49d84a9df had a single option, --mysqld to obtain the required innodb_log_group_home_dir. 83664e21e4fb675 enumberated the groups when --mysqld was sufficient. --- scripts/wsrep_sst_rsync.sh | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index c6e8a7ef4e1..de881459975 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -102,19 +102,7 @@ fi 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 - WSREP_LOG_DIR=$(parse_cnf mariadb-10.0 innodb_log_group_home_dir "") -fi -if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$(parse_cnf mysqld innodb_log_group_home_dir "") -fi -if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$(parse_cnf server innodb_log_group_home_dir "") -fi -if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$(parse_cnf mariadb innodb_log_group_home_dir "") -fi -if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$(parse_cnf mysqld-10.0 innodb_log_group_home_dir "") + WSREP_LOG_DIR=$(parse_cnf --mysqld innodb_log_group_home_dir "") fi if [ -n "$WSREP_LOG_DIR" ]; then From 67f3fb1bc54682a29ee3b407f60b798780db698f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 2 Jan 2018 14:26:48 +1100 Subject: [PATCH 02/13] galera_recovery: misses reading default configuration groups --- scripts/galera_recovery.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh index de2e653c497..f6a06a7e8e0 100644 --- a/scripts/galera_recovery.sh +++ b/scripts/galera_recovery.sh @@ -107,8 +107,7 @@ else log "WSREP: mktemp failed" fi -parse_arguments `$print_defaults $cmdline_args --loose-verbose \ - mariadb mariadb_safe mysqld mysqld_safe safe_mysqld galera` +parse_arguments `$print_defaults $cmdline_args --loose-verbose --mysqld` # Perform wsrep position recovery if wsrep_on=1, skip otherwise. if [ "$wsrep_on" -eq 1 ]; then From 46d5e1f2fddbb4589a8763508cea8589941a2b2f Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 26 Jul 2018 15:42:06 +0200 Subject: [PATCH 03/13] MDEV-10754 wsrep_sst_rsync does not support innodb_data_home_dir If innodb_data_home_dir path specified in the configuration file then rsync IST/SST will fail because the wsrep_sst_rsync.sh script does not read this parameter from the configuration file and then tries to find the data files in the default directory. To fix this error, we need to add reading of the innodb_data_home_dir configuration parameter to the rsync-related SST script. --- .../galera/r/galera_sst_rsync_data_dir.result | 288 ++++++++++++++++++ .../galera/t/galera_sst_rsync_data_dir.cnf | 11 + .../galera/t/galera_sst_rsync_data_dir.test | 17 ++ scripts/wsrep_sst_rsync.sh | 9 +- 4 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result new file mode 100644 index 00000000000..ff85a7d6c0f --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result @@ -0,0 +1,288 @@ +connection node_1; +connection node_2; +Performing State Transfer on a server that has been shut down cleanly and restarted +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_shutdown_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that starts from a clean var directory +This is accomplished by shutting down node #2 and removing its var directory before restarting it +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +Cleaning var directory ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_clean_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_clean_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that has been killed and restarted +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Killing server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Performing --wsrep-recover ... +Starting server ... +Using --wsrep-start-position when starting mysqld ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_kill_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf new file mode 100644 index 00000000000..d084740c8a6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync +innodb_data_home_dir=@ENV.MYSQL_TMP_DIR/rsync_test + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test new file mode 100644 index 00000000000..6220836c11d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test @@ -0,0 +1,17 @@ +--source include/big_test.inc +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc + +# cleanup temporary database files: +--remove_files_wildcard $MYSQL_TMP_DIR/rsync_test * +--rmdir $MYSQL_TMP_DIR/rsync_test diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 81120b66d5a..3659a60832c 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -113,6 +113,12 @@ else WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P) fi +INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""} +# if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf +if [ -z "INNODB_DATA_HOME_DIR" ]; then + INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '') +fi + # Old filter - include everything except selected # FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \ # --exclude '*.conf' --exclude core --exclude 'galera.*' \ @@ -121,7 +127,8 @@ fi # New filter - exclude everything except dirs (schemas) and innodb files FILTER=(-f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes' - -f '+ /wsrep_sst_binlog.tar' -f '+ /ib_lru_dump' -f '+ /ibdata*' -f '+ /*/' -f '- /*') + -f '+ /wsrep_sst_binlog.tar' -f '+ $INNODB_DATA_HOME_DIR/ib_lru_dump' + -f '+ $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /*/' -f '- /*') if [ "$WSREP_SST_OPT_ROLE" = "donor" ] then From 7e8ed15b95b64af2068a3515fe97f2c245311323 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 9 Aug 2018 02:24:12 +0000 Subject: [PATCH 04/13] Fixes after review and correction of the problems caused by the fact that during the SST innodb plugin is not yet initialized, as well as problems with running tests from the root user (not directly related to the MDEV-10754). --- .../galera/include/galera_wsrep_recover.inc | 9 ++++ .../galera/t/galera_sst_rsync_data_dir.cnf | 2 +- .../galera/t/galera_sst_rsync_data_dir.test | 3 +- scripts/wsrep_sst_common.sh | 2 + scripts/wsrep_sst_rsync.sh | 33 ++++++++++-- sql/wsrep_mysqld.h | 1 + sql/wsrep_sst.cc | 50 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 6 +++ 8 files changed, 99 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/galera/include/galera_wsrep_recover.inc b/mysql-test/suite/galera/include/galera_wsrep_recover.inc index 090ffe5f5df..7f1ed1a875d 100644 --- a/mysql-test/suite/galera/include/galera_wsrep_recover.inc +++ b/mysql-test/suite/galera/include/galera_wsrep_recover.inc @@ -1,5 +1,14 @@ --echo Performing --wsrep-recover ... +# +# When mysqld is run by a root user it will fail to start unless +# we specify what user is ran it (using "--user root" option): +# +if ($MYSQL_TEST_ROOT == 1) { +--exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --innodb --wsrep-recover --user root > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 +} +if ($MYSQL_TEST_ROOT != 1) { --exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --innodb --wsrep-recover > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 +} --perl use strict; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf index d084740c8a6..afe9796a11a 100644 --- a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf +++ b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.cnf @@ -2,10 +2,10 @@ [mysqld] wsrep_sst_method=rsync -innodb_data_home_dir=@ENV.MYSQL_TMP_DIR/rsync_test [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' [mysqld.2] +innodb_data_home_dir=@ENV.MYSQL_TMP_DIR/rsync_test_2 wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test index 6220836c11d..68aa1068f75 100644 --- a/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test +++ b/mysql-test/suite/galera/t/galera_sst_rsync_data_dir.test @@ -13,5 +13,4 @@ --source include/auto_increment_offset_restore.inc # cleanup temporary database files: ---remove_files_wildcard $MYSQL_TMP_DIR/rsync_test * ---rmdir $MYSQL_TMP_DIR/rsync_test +--remove_files_wildcard $MYSQL_TMP_DIR/rsync_test_2 * diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index e160bf5c776..7f1f44d0cdb 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -27,6 +27,7 @@ WSREP_SST_OPT_PSWD=${WSREP_SST_OPT_PSWD:-} WSREP_SST_OPT_DEFAULT="" WSREP_SST_OPT_EXTRA_DEFAULT="" WSREP_SST_OPT_SUFFIX_DEFAULT="" +WSREP_SST_OPT_SUFFIX_VALUE="" while [ $# -gt 0 ]; do case "$1" in @@ -76,6 +77,7 @@ case "$1" in ;; '--defaults-group-suffix') readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2" + readonly WSREP_SST_OPT_SUFFIX_VALUE="$2" shift ;; '--host') diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 6d8d5d1168a..0962e59f437 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -123,8 +123,16 @@ fi INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""} # if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf -if [ -z "INNODB_DATA_HOME_DIR" ]; then - INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '') +if [ -z "$INNODB_DATA_HOME_DIR" ]; then + INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '') +fi + +if [ -n "$INNODB_DATA_HOME_DIR" ]; then + # handle both relative and absolute paths + INNODB_DATA_HOME_DIR=$(cd $WSREP_SST_OPT_DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P) +else + # default to datadir + INNODB_DATA_HOME_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P) fi # Old filter - include everything except selected @@ -135,8 +143,8 @@ fi # New filter - exclude everything except dirs (schemas) and innodb files FILTER=(-f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes' - -f '+ /wsrep_sst_binlog.tar' -f '+ $INNODB_DATA_HOME_DIR/ib_lru_dump' - -f '+ $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /*/' -f '- /*') + -f '+ /wsrep_sst_binlog.tar' -f '- $INNODB_DATA_HOME_DIR/ib_lru_dump' + -f '- $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /*/' -f '- /*'" SSTKEY=$(parse_cnf sst tkey "") SSTCERT=$(parse_cnf sst tcert "") @@ -242,6 +250,19 @@ EOF exit $RC fi + # Transfer InnoDB data files + rsync ${STUNNEL:+--rsh="$STUNNEL"} \ + --owner --group --perms --links --specials \ + --ignore-times --inplace --dirs --delete --quiet \ + $WHOLE_FILE_OPT -f '+ /ibdata*' -f '+ /ib_lru_dump' \ + -f '- **' "$INNODB_DATA_HOME_DIR/" \ + rsync://$WSREP_SST_OPT_ADDR-data_dir >&2 || RC=$? + + if [ $RC -ne 0 ]; then + wsrep_log_error "rsync innodb_data_home_dir returned code $RC:" + exit 255 # unknown error + fi + # second, we transfer InnoDB log files rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials \ @@ -340,8 +361,12 @@ $SILENT path = $WSREP_SST_OPT_DATA [$MODULE-log_dir] path = $WSREP_LOG_DIR +[$MODULE-data_dir] + path = $INNODB_DATA_HOME_DIR EOF +[ "$(whoami)" != root ] || sed -i '/read only = no/s/.*/&\nuid = root\ngid = root\n/' "$RSYNC_CONF" + # rm -rf "$DATA"/ib_logfile* # we don't want old logs around # listen at all interfaces (for firewalled setups) diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 272e4ac4984..9fc8aa02df4 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -160,6 +160,7 @@ extern "C" time_t wsrep_thd_query_start(THD *thd); extern "C" query_id_t wsrep_thd_query_id(THD *thd); extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd); extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id); +extern "C" void wsrep_set_data_home_dir(const char *data_dir); extern void wsrep_close_client_connections(my_bool wait_to_end); extern int wsrep_wait_committing_connections_close(int wait_time); diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 155051bfe84..0274a364bc5 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -67,6 +67,13 @@ bool wsrep_sst_method_update (sys_var *self, THD* thd, enum_var_type type) return 0; } +static const char* data_home_dir = NULL; + +extern "C" +void wsrep_set_data_home_dir(const char *data_dir) +{ + data_home_dir= (data_dir && *data_dir) ? data_dir : NULL; +} static void make_wsrep_defaults_file() { @@ -549,6 +556,29 @@ static int sst_append_auth_env(wsp::env& env, const char* sst_auth) return -env.error(); } +#define DATA_HOME_DIR_ENV "INNODB_DATA_HOME_DIR" + +static int sst_append_data_dir(wsp::env& env, const char* data_dir) +{ + int const data_dir_size= strlen(DATA_HOME_DIR_ENV) + 1 /* = */ + + (data_dir ? strlen(data_dir) : 0) + 1 /* \0 */; + + wsp::string data_dir_str(data_dir_size); // for automatic cleanup on return + if (!data_dir_str()) return -ENOMEM; + + int ret= snprintf(data_dir_str(), data_dir_size, "%s=%s", + DATA_HOME_DIR_ENV, data_dir ? data_dir : ""); + + if (ret < 0 || ret >= data_dir_size) + { + WSREP_ERROR("sst_append_data_dir(): snprintf() failed: %d", ret); + return (ret < 0 ? ret : -EMSGSIZE); + } + + env.append(data_dir_str()); + return -env.error(); +} + static ssize_t sst_prepare_other (const char* method, const char* sst_auth, const char* addr_in, @@ -610,6 +640,16 @@ static ssize_t sst_prepare_other (const char* method, return ret; } + if (data_home_dir) + { + if ((ret= sst_append_data_dir(env, data_home_dir))) + { + WSREP_ERROR("sst_prepare_other(): appending data " + "directory failed: %d", ret); + return ret; + } + } + pthread_t tmp; sst_thread_arg arg(cmd_str(), env()); mysql_mutex_lock (&arg.lock); @@ -1301,6 +1341,16 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx, return WSREP_CB_FAILURE; } + if (data_home_dir) + { + if ((ret= sst_append_data_dir(env, data_home_dir))) + { + WSREP_ERROR("wsrep_sst_donate_cb(): appending data " + "directory failed: %d", ret); + return WSREP_CB_FAILURE; + } + } + if (!strcmp (WSREP_SST_MYSQLDUMP, method)) { ret = sst_donate_mysqldump(data, ¤t_gtid->uuid, uuid_str, diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5667efea5df..d2701ecfc0b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3623,6 +3623,12 @@ innobase_init( srv_data_home = (innobase_data_home_dir ? innobase_data_home_dir : default_path); +#ifdef WITH_WSREP + /* If we use the wsrep API, then we need to tell the server + the path to the data files (for passing it to the SST scripts): */ + wsrep_set_data_home_dir(innobase_data_home_dir); +#endif /* WITH_WSREP */ + /* Set default InnoDB data file size to 12 MB and let it be auto-extending. Thus users can use InnoDB in >= 4.0 without having to specify any startup options. */ From 36832711c15cc3208f4d76ff6677488ea4bb11a4 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 13 Aug 2018 10:40:47 +0200 Subject: [PATCH 05/13] Reverting changes made to support the mtr under the root --- mysql-test/suite/galera/include/galera_wsrep_recover.inc | 9 --------- scripts/wsrep_sst_rsync.sh | 2 -- 2 files changed, 11 deletions(-) diff --git a/mysql-test/suite/galera/include/galera_wsrep_recover.inc b/mysql-test/suite/galera/include/galera_wsrep_recover.inc index 7f1ed1a875d..090ffe5f5df 100644 --- a/mysql-test/suite/galera/include/galera_wsrep_recover.inc +++ b/mysql-test/suite/galera/include/galera_wsrep_recover.inc @@ -1,14 +1,5 @@ --echo Performing --wsrep-recover ... -# -# When mysqld is run by a root user it will fail to start unless -# we specify what user is ran it (using "--user root" option): -# -if ($MYSQL_TEST_ROOT == 1) { ---exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --innodb --wsrep-recover --user root > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 -} -if ($MYSQL_TEST_ROOT != 1) { --exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --innodb --wsrep-recover > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 -} --perl use strict; diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 0962e59f437..f787262085b 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -365,8 +365,6 @@ $SILENT path = $INNODB_DATA_HOME_DIR EOF -[ "$(whoami)" != root ] || sed -i '/read only = no/s/.*/&\nuid = root\ngid = root\n/' "$RSYNC_CONF" - # rm -rf "$DATA"/ib_logfile* # we don't want old logs around # listen at all interfaces (for firewalled setups) From 4ff7f14feffc8cbb685910ecd595095629f7a764 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 17 Aug 2018 15:54:55 +0200 Subject: [PATCH 06/13] Fixes of the base patch for compatibility with the 10.1 branch --- .../galera/r/galera_sst_rsync_data_dir.result | 26 ------------------- scripts/wsrep_sst_rsync.sh | 2 +- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result index ff85a7d6c0f..cec0f21ee22 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync_data_dir.result @@ -1,7 +1,4 @@ -connection node_1; -connection node_2; Performing State Transfer on a server that has been shut down cleanly and restarted -connection node_1; CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -11,7 +8,6 @@ INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); COMMIT; -connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node2_committed_before'); @@ -21,7 +17,6 @@ INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); COMMIT; Shutting down server ... -connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node1_committed_during'); @@ -36,7 +31,6 @@ INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); -connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -44,7 +38,6 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); -connection node_2; Starting server ... SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -54,7 +47,6 @@ INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); COMMIT; -connection node_1; INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); @@ -69,7 +61,6 @@ INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); COMMIT; -connection node_1a_galera_st_shutdown_slave; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -84,7 +75,6 @@ COUNT(*) = 0 1 COMMIT; SET AUTOCOMMIT=ON; -connection node_1; SELECT COUNT(*) = 35 FROM t1; COUNT(*) = 35 1 @@ -96,7 +86,6 @@ COMMIT; SET AUTOCOMMIT=ON; Performing State Transfer on a server that starts from a clean var directory This is accomplished by shutting down node #2 and removing its var directory before restarting it -connection node_1; CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -106,7 +95,6 @@ INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); COMMIT; -connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node2_committed_before'); @@ -116,7 +104,6 @@ INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); COMMIT; Shutting down server ... -connection node_1; Cleaning var directory ... SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -132,7 +119,6 @@ INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); -connect node_1a_galera_st_clean_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -140,7 +126,6 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); -connection node_2; Starting server ... SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -150,7 +135,6 @@ INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); COMMIT; -connection node_1; INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); @@ -165,7 +149,6 @@ INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); COMMIT; -connection node_1a_galera_st_clean_slave; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -180,7 +163,6 @@ COUNT(*) = 0 1 COMMIT; SET AUTOCOMMIT=ON; -connection node_1; SELECT COUNT(*) = 35 FROM t1; COUNT(*) = 35 1 @@ -191,7 +173,6 @@ DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; Performing State Transfer on a server that has been killed and restarted -connection node_1; CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -201,7 +182,6 @@ INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); INSERT INTO t1 VALUES ('node1_committed_before'); COMMIT; -connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node2_committed_before'); @@ -211,7 +191,6 @@ INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); COMMIT; Killing server ... -connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node1_committed_during'); @@ -226,7 +205,6 @@ INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); -connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -234,7 +212,6 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); -connection node_2; Performing --wsrep-recover ... Starting server ... Using --wsrep-start-position when starting mysqld ... @@ -246,7 +223,6 @@ INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); INSERT INTO t1 VALUES ('node2_committed_after'); COMMIT; -connection node_1; INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); INSERT INTO t1 VALUES ('node1_to_be_committed_after'); @@ -261,7 +237,6 @@ INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); INSERT INTO t1 VALUES ('node1_committed_after'); COMMIT; -connection node_1a_galera_st_kill_slave; INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); @@ -276,7 +251,6 @@ COUNT(*) = 0 1 COMMIT; SET AUTOCOMMIT=ON; -connection node_1; SELECT COUNT(*) = 35 FROM t1; COUNT(*) = 35 1 diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index f787262085b..77a25ffc530 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -144,7 +144,7 @@ fi # New filter - exclude everything except dirs (schemas) and innodb files FILTER=(-f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes' -f '+ /wsrep_sst_binlog.tar' -f '- $INNODB_DATA_HOME_DIR/ib_lru_dump' - -f '- $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /*/' -f '- /*'" + -f '- $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /*/' -f '- /*') SSTKEY=$(parse_cnf sst tkey "") SSTCERT=$(parse_cnf sst tcert "") From cded083a370f4b23c6d895d44f2948c267ed5e77 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 27 Aug 2018 22:00:14 +0300 Subject: [PATCH 07/13] MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes Problem was that a parallel open of a table, overwrote info->state that was in used by repair. Fixed by changing _ma_tmp_disable_logging_for_table() to use a new state buffer state.no_logging to store the temporary state. Other things: - Use original number of rows when retrying repair to get rid of a potential warning "Number of rows changed from X to Y" - Changed maria_commit() to make it easier to merge with 10.4 - If table is not locked (like with show commands), use the global number of rows as the local number may not be up to date. (Minor not critical fix) - Added some missing DBUG_RETURN --- mysql-test/suite/maria/concurrent.result | 28 ++++++++++++++++++++++++ mysql-test/suite/maria/concurrent.test | 28 ++++++++++++++++++++++++ storage/maria/ha_maria.cc | 3 +++ storage/maria/ma_commit.c | 2 +- storage/maria/ma_info.c | 6 ++++- storage/maria/ma_recovery.c | 8 +++++-- storage/maria/maria_chk.c | 4 ++-- storage/maria/maria_def.h | 2 ++ 8 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/maria/concurrent.result create mode 100644 mysql-test/suite/maria/concurrent.test diff --git a/mysql-test/suite/maria/concurrent.result b/mysql-test/suite/maria/concurrent.result new file mode 100644 index 00000000000..5498a6410a2 --- /dev/null +++ b/mysql-test/suite/maria/concurrent.result @@ -0,0 +1,28 @@ +CREATE TABLE t1 (a INT, b CHAR(12), c INT, FULLTEXT KEY(b), KEY (c)) ENGINE=Aria; +CREATE TABLE t2 (a INT, b CHAR(12), c INT) ENGINE=Aria; +INSERT INTO t2 VALUES (1,'foo',8), (2,'bar',9); +INSERT INTO t1 SELECT * FROM t2; +select 1; +1 +1 +select 1; +1 +1 +select 1; +1 +1 +select 1; +1 +1 +select 1; +1 +1 +select 1; +1 +1 +select 1; +1 +1 +SELECT * FROM t1 WHERE a = ( SELECT 1 FROM non_existing_table2 ); +ERROR 42S02: Table 'test.non_existing_table2' doesn't exist +DROP TABLE t1, t2; diff --git a/mysql-test/suite/maria/concurrent.test b/mysql-test/suite/maria/concurrent.test new file mode 100644 index 00000000000..42adb082d40 --- /dev/null +++ b/mysql-test/suite/maria/concurrent.test @@ -0,0 +1,28 @@ +# +# MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes +# + +CREATE TABLE t1 (a INT, b CHAR(12), c INT, FULLTEXT KEY(b), KEY (c)) ENGINE=Aria; +CREATE TABLE t2 (a INT, b CHAR(12), c INT) ENGINE=Aria; +INSERT INTO t2 VALUES (1,'foo',8), (2,'bar',9); + +--connect (con1,localhost,root,,test) +--send + INSERT INTO t1 SELECT * FROM t2; +--connection default +select 1; +select 1; +select 1; +select 1; +select 1; +select 1; +select 1; +--error ER_NO_SUCH_TABLE +SELECT * FROM t1 WHERE a = ( SELECT 1 FROM non_existing_table2 ); +--connection con1 +--reap + +# Cleanup +--disconnect con1 +--connection default +DROP TABLE t1, t2; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index eee6b502c47..d438aa90378 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1460,6 +1460,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) while ((error= repair(thd, param, 0)) && param->retry_repair) { param->retry_repair= 0; + file->state->records= start_records; if (test_all_bits(param->testflag, (uint) (T_RETRY_WITHOUT_QUICK | T_QUICK))) { @@ -1961,6 +1962,7 @@ int ha_maria::disable_indexes(uint mode) int ha_maria::enable_indexes(uint mode) { int error; + ha_rows start_rows= file->state->records; DBUG_PRINT("info", ("ha_maria::enable_indexes mode: %d", mode)); if (maria_is_all_keys_active(file->s->state.key_map, file->s->base.keys)) { @@ -2023,6 +2025,7 @@ int ha_maria::enable_indexes(uint mode) DBUG_ASSERT(thd->killed != 0); /* Repairing by sort failed. Now try standard repair method. */ param->testflag &= ~T_REP_BY_SORT; + file->state->records= start_rows; error= (repair(thd, param, 0) != HA_ADMIN_OK); /* If the standard repair succeeded, clear all error messages which diff --git a/storage/maria/ma_commit.c b/storage/maria/ma_commit.c index 0ae3868dbf6..3850af8246c 100644 --- a/storage/maria/ma_commit.c +++ b/storage/maria/ma_commit.c @@ -98,7 +98,7 @@ int maria_commit(MARIA_HA *info) if (!info->s->now_transactional) return 0; trn= info->trn; - info->trn= 0; /* checked in maria_close() */ + _ma_reset_trn_for_table(info); return ma_commit(trn); } diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index 1189594fd2b..da44da123d2 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -56,7 +56,11 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag) } if (flag & HA_STATUS_VARIABLE) { - x->records = info->state->records; + /* If table is locked, give versioned number otherwise last commited */ + if (info->lock_type == F_UNLCK) + x->records = share->state.state.records; + else + x->records = info->state->records; x->deleted = share->state.state.del; x->delete_length = share->state.state.empty; x->data_file_length = share->state.state.data_file_length; diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index c06e46c104f..f023dde7817 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3551,8 +3551,8 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info, info->state may point to a state that was deleted by _ma_trnman_end_trans_hook() */ - share->state.common= *info->state; - info->state= &share->state.common; + share->state.no_logging= *info->state; + info->state= &share->state.no_logging; info->switched_transactional= TRUE; /* @@ -3608,6 +3608,10 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages) _ma_copy_nontrans_state_information(info); _ma_reset_history(info->s); + /* Reset state to point to state.common, as on open() */ + info->state= &share->state.common; + *info->state= share->state.state; + if (flush_pages) { /* Ensure that recover is not executing any redo before this */ diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index b47f1b8c824..d03c50891df 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -1128,7 +1128,7 @@ static int maria_chk(HA_CHECK *param, char *filename) { fprintf(stderr, "Aria table '%s' is not fixed because of errors\n", filename); - return(-1); + DBUG_RETURN(-1); } recreate=1; if (!(param->testflag & T_REP_ANY)) @@ -1150,7 +1150,7 @@ static int maria_chk(HA_CHECK *param, char *filename) param->total_deleted+=info->state->del; descript(param, info, filename); maria_close(info); /* Should always succeed */ - return(0); + DBUG_RETURN(0); } if (!stopwords_inited++) diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 8262e1b5e2d..128e78da32b 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -149,6 +149,8 @@ typedef struct st_maria_state_info MARIA_STATUS_INFO state; /* maria_ha->state points here for crash-safe but not versioned tables */ MARIA_STATUS_INFO common; + /* State for a versioned table that is temporary non versioned */ + MARIA_STATUS_INFO no_logging; ha_rows split; /* number of split blocks */ my_off_t dellink; /* Link to next removed block */ pgcache_page_no_t first_bitmap_with_space; From 6c588c92a9b17c5478c60713c7d5b17a38044295 Mon Sep 17 00:00:00 2001 From: Ian Gilfillan Date: Thu, 9 Aug 2018 13:22:30 +0200 Subject: [PATCH 08/13] MDEV-14927: Missing man pages --- man/CMakeLists.txt | 6 ++++-- man/mariabackup.1 | 16 ++++++++++++++++ man/mbstream.1 | 16 ++++++++++++++++ man/mysql_embedded.1 | 1 + man/{tokuft_logdump.1 => tokuft_logprint.1} | 2 +- man/wsrep_sst_mariabackup.1 | 16 ++++++++++++++++ man/wsrep_sst_rsync.1 | 4 ++-- man/wsrep_sst_rsync_wan.1 | 16 ++++++++++++++++ 8 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 man/mariabackup.1 create mode 100644 man/mbstream.1 create mode 100644 man/mysql_embedded.1 rename man/{tokuft_logdump.1 => tokuft_logprint.1} (84%) create mode 100644 man/wsrep_sst_mariabackup.1 create mode 100644 man/wsrep_sst_rsync_wan.1 diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index fdefade6c0d..75e5615a6a2 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -26,12 +26,14 @@ SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1 mysqld_safe_helper.1 tokuftdump.1 wsrep_sst_common.1 wsrep_sst_mysqldump.1 wsrep_sst_rsync.1 wsrep_sst_xtrabackup-v2.1 wsrep_sst_xtrabackup.1 - galera_recovery.1 galera_new_cluster.1 tokuft_logdump.1) + galera_recovery.1 galera_new_cluster.1 tokuft_logprint.1 + wsrep_sst_mariabackup.1 mbstream.1 mariabackup.1 + wsrep_sst_rsync_wan.1) SET(MAN8_SERVER mysqld.8) SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1 mysqlaccess.1 mysqladmin.1 mysqlbinlog.1 mysqlcheck.1 mysqldump.1 mysqlimport.1 mysqlshow.1 mysqlslap.1 - mysql_plugin.1) + mysql_plugin.1 mysql_embedded.1) SET(MAN1_DEVEL mysql_config.1) SET(MAN1_TEST mysql-stress-test.pl.1 mysql-test-run.pl.1 mysql_client_test.1 mysqltest_embedded.1 mysql_client_test_embedded.1 my_safe_process.1) diff --git a/man/mariabackup.1 b/man/mariabackup.1 new file mode 100644 index 00000000000..628c9cf74fa --- /dev/null +++ b/man/mariabackup.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBMARIABACKUP\FR" "1" "9 August 2018" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +mariabackup \- Backup tool +.SH DESCRIPTION +Use \fBmariabackup \-\-help\fR for details on usage\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ diff --git a/man/mbstream.1 b/man/mbstream.1 new file mode 100644 index 00000000000..2aba73fe400 --- /dev/null +++ b/man/mbstream.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBMBSTREAM\FR" "1" "9 August 2018" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +mbstream \- Serialize/deserialize files in the XBSTREAM format +.SH DESCRIPTION +Use \fBmbstream \-\-help\fR for details on usage\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ diff --git a/man/mysql_embedded.1 b/man/mysql_embedded.1 new file mode 100644 index 00000000000..735c4e05ae0 --- /dev/null +++ b/man/mysql_embedded.1 @@ -0,0 +1 @@ +.so man1/mysql.1 diff --git a/man/tokuft_logdump.1 b/man/tokuft_logprint.1 similarity index 84% rename from man/tokuft_logdump.1 rename to man/tokuft_logprint.1 index f6cf08080f7..bc3b85a55d6 100644 --- a/man/tokuft_logdump.1 +++ b/man/tokuft_logprint.1 @@ -11,6 +11,6 @@ .SH NAME tokuft_logprint \- Dump the log from stdin to stdout .SH DESCRIPTION -Use: Dump the log from stdin to stdout\. +Use: Dump the log from stdin to stdout\. Use \fBtokuft_logprint \-\-help\fR for details on usage\. .PP For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ diff --git a/man/wsrep_sst_mariabackup.1 b/man/wsrep_sst_mariabackup.1 new file mode 100644 index 00000000000..34ae4b6f82e --- /dev/null +++ b/man/wsrep_sst_mariabackup.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBWSREP_SST_MARIABACKUP\FR" "1" "8 August 2018" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +wsrep_sst_mariabackup \- mariabackup\-based state snapshot transfer +.SH DESCRIPTION +Use: mariabackup-based state snapshot transfer\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ diff --git a/man/wsrep_sst_rsync.1 b/man/wsrep_sst_rsync.1 index 95a80b20821..85a8c221609 100644 --- a/man/wsrep_sst_rsync.1 +++ b/man/wsrep_sst_rsync.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_RSYNC\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System" +.TH "\FBWSREP_SST_RSYNC\FR" "1" "9 August 2018" "MariaDB 10\&.1" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -9,7 +9,7 @@ .\" disable justification (adjust text to left margin only) .ad l .SH NAME -wsrep_sst_mysqldump \- rsync-based state snapshot transfer +wsrep_sst_rsync \- rsync-based state snapshot transfer .SH DESCRIPTION Use: rsync-based state snapshot transfer\. .PP diff --git a/man/wsrep_sst_rsync_wan.1 b/man/wsrep_sst_rsync_wan.1 new file mode 100644 index 00000000000..6d465d554a8 --- /dev/null +++ b/man/wsrep_sst_rsync_wan.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBWSREP_SST_RSYNC_WAN\FR" "1" "9 August 2018" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +wsrep_sst_rsync_wan \- rsync_wan (rsync with delta transfers)\-based state snapshot transfer +.SH DESCRIPTION +Use: rsync_wan\-based state snapshot transfer\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ From 104089e182f31524d85409bd59f1889e36d4636a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 29 Aug 2018 19:30:03 +0300 Subject: [PATCH 09/13] MDEV-15512 - Fix sh parse error when [sst] config value has spaces. Merged https://github.com/MariaDB/server/pull/617 authored by Colin Mollenhour. --- scripts/wsrep_sst_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 7f1f44d0cdb..bc26cec6d83 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -277,8 +277,8 @@ parse_cnf() reval=$($MY_PRINT_DEFAULTS "${group}" | awk -v var="${var}" 'BEGIN { OFS=FS="=" } { gsub(/_/,"-",$1); if ( $1=="--"var) lastval=substr($0,length($1)+2) } END { print lastval}') # use default if we haven't found a value - if [ -z $reval ]; then - [ -n $3 ] && reval=$3 + if [ -z "$reval" ]; then + [ -n "$3" ] && reval=$3 fi echo $reval } From 2ad51a0bd8380fba3d03a4cebd43860329b7fbaa Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 30 Aug 2018 14:51:15 +0400 Subject: [PATCH 10/13] MDEV-17095 pam_user_map module throws syntax error if group name contains backslash. Let '\\' and '/' symbols to be part of a group name. --- plugin/auth_pam/mapper/pam_user_map.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c index c03ea12be74..e1d11acabb9 100644 --- a/plugin/auth_pam/mapper/pam_user_map.c +++ b/plugin/auth_pam/mapper/pam_user_map.c @@ -189,13 +189,15 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, s++; } from= s; - skip(isalnum(*s) || (*s == '_') || (*s == '.') || (*s == '-') || (*s == '$')); + skip(isalnum(*s) || (*s == '_') || (*s == '.') || (*s == '-') || + (*s == '$') || (*s == '\\') || (*s == '/')); end_from= s; skip(isspace(*s)); if (end_from == from || *s++ != ':') goto syntax_error; skip(isspace(*s)); to= s; - skip(isalnum(*s) || (*s == '_') || (*s == '.') || (*s == '-') || (*s == '$')); + skip(isalnum(*s) || (*s == '_') || (*s == '.') || (*s == '-') || + (*s == '$')); end_to= s; if (end_to == to) goto syntax_error; From c933970974bd5a30fb824c1df64c68f1bc403389 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 30 Aug 2018 15:57:22 +0400 Subject: [PATCH 11/13] MDEV-16665 ed25519 describes itself as 1.0-alpha even though it's not alpha. Plugin version name fixed. --- mysql-test/suite/plugins/r/auth_ed25519.result | 2 +- plugin/auth_ed25519/server_ed25519.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/plugins/r/auth_ed25519.result b/mysql-test/suite/plugins/r/auth_ed25519.result index 371d20befeb..240e226f594 100644 --- a/mysql-test/suite/plugins/r/auth_ed25519.result +++ b/mysql-test/suite/plugins/r/auth_ed25519.result @@ -33,7 +33,7 @@ PLUGIN_DESCRIPTION Elliptic curve ED25519 based authentication PLUGIN_LICENSE GPL LOAD_OPTION ON PLUGIN_MATURITY Stable -PLUGIN_AUTH_VERSION 1.0-alpha +PLUGIN_AUTH_VERSION 1.0 create user test1@localhost identified via ed25519 using 'ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY'; show grants for test1@localhost; Grants for test1@localhost diff --git a/plugin/auth_ed25519/server_ed25519.c b/plugin/auth_ed25519/server_ed25519.c index 7720a0a4074..8e442e56804 100644 --- a/plugin/auth_ed25519/server_ed25519.c +++ b/plugin/auth_ed25519/server_ed25519.c @@ -101,7 +101,7 @@ maria_declare_plugin(ed25519) 0x0100, NULL, NULL, - "1.0-alpha", + "1.0", MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; From 3b5d3cd68e4acceb613822adc66b87f396920e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 31 Aug 2018 11:41:59 +0300 Subject: [PATCH 12/13] Revert MDEV-9519 due to regressions This reverts commit 75dfd4acb995789ca5f86ccbd361fff9d2797e79. --- .../r/galera_binlog_stmt_autoinc.result | 147 ------------ .../galera/t/galera_binlog_stmt_autoinc.test | 223 ------------------ sql/field.h | 46 ---- sql/handler.cc | 31 +-- sql/mysqld.cc | 14 -- sql/sql_class.h | 11 - sql/sys_vars.cc | 93 +------- sql/wsrep_mysqld.h | 4 - sql/wsrep_thd.cc | 22 -- storage/innobase/handler/ha_innodb.cc | 59 ++--- storage/xtradb/handler/ha_innodb.cc | 57 +---- 11 files changed, 30 insertions(+), 677 deletions(-) delete mode 100644 mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result delete mode 100644 mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result deleted file mode 100644 index 542bd156816..00000000000 --- a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result +++ /dev/null @@ -1,147 +0,0 @@ -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -SET GLOBAL wsrep_forced_binlog_format='none'; -SET GLOBAL wsrep_forced_binlog_format='none'; -drop table t1; -SET SESSION binlog_format='STATEMENT'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format STATEMENT -SET GLOBAL wsrep_auto_increment_control='OFF'; -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -SET GLOBAL wsrep_auto_increment_control='ON'; -SET SESSION binlog_format='ROW'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format ROW -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 2 -auto_increment_offset 1 -wsrep_auto_increment_control ON -SET GLOBAL wsrep_auto_increment_control='OFF'; -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 3 -auto_increment_offset 1 -wsrep_auto_increment_control OFF -SET GLOBAL wsrep_auto_increment_control='ON'; -drop table t1; -SET GLOBAL wsrep_forced_binlog_format='ROW'; -SET GLOBAL wsrep_forced_binlog_format='ROW'; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -SET GLOBAL wsrep_forced_binlog_format='none'; -SET GLOBAL wsrep_forced_binlog_format='none'; -drop table t1; -SET SESSION binlog_format='ROW'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format ROW -SET GLOBAL wsrep_auto_increment_control='OFF'; -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -SET GLOBAL wsrep_auto_increment_control='ON'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format ROW -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 2 -auto_increment_offset 1 -wsrep_auto_increment_control ON -SET GLOBAL wsrep_auto_increment_control='OFF'; -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 3 -auto_increment_offset 1 -wsrep_auto_increment_control OFF -SET GLOBAL wsrep_auto_increment_control='ON'; -drop table t1; diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test deleted file mode 100644 index aab4fea9f2e..00000000000 --- a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test +++ /dev/null @@ -1,223 +0,0 @@ -## -## Tests the auto-increment with binlog in STATEMENT mode. -## - ---source include/galera_cluster.inc ---source include/have_innodb.inc - ---let $node_1=node_1 ---let $node_2=node_2 ---source include/auto_increment_offset_save.inc - -## -## Verify the correct operation of the auto-increment when the binlog -## format artificially set to the 'STATEMENT' (although this mode is -## not recommended in the current version): -## - ---connection node_2 -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; - ---connection node_1 -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - -SET GLOBAL wsrep_forced_binlog_format='none'; - ---connection node_1 - -SET GLOBAL wsrep_forced_binlog_format='none'; - -drop table t1; - -## -## Check the operation when the automatic control over the auto-increment -## settings is switched off, that is, when we use the increment step and -## the offset specified by the user. In the current session, the binlog -## format is set to 'STATEMENT'. It is important that the values of the -## auto-increment options does not changed on other node - it allows us -## to check the correct transmission of the auto-increment options to -## other nodes: -## - ---disable_warnings -SET SESSION binlog_format='STATEMENT'; ---enable_warnings - -show variables like 'binlog_format'; - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - ---connection node_1 - -## -## Verify the return to automatic calculation of the step -## and offset of the auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -SET SESSION binlog_format='ROW'; - -show variables like 'binlog_format'; -show variables like '%auto_increment%'; - -## -## Verify the recovery of original user-defined values after -## stopping the automatic control over auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -show variables like '%auto_increment%'; - -## -## Restore original options and drop test table: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -drop table t1; - -## -## Verify the correct operation of the auto-increment when the binlog -## format set to the 'ROW': -## - ---connection node_2 -SET GLOBAL wsrep_forced_binlog_format='ROW'; - ---connection node_1 -SET GLOBAL wsrep_forced_binlog_format='ROW'; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - -SET GLOBAL wsrep_forced_binlog_format='none'; - ---connection node_1 - -SET GLOBAL wsrep_forced_binlog_format='none'; - -drop table t1; - -## -## Check the operation when the automatic control over the auto-increment -## settings is switched off, that is, when we use the increment step and -## the offset specified by the user. In the current session, the binlog -## format is set to 'ROW'. It is important that the values of the -## auto-increment options does not changed on other node - it allows us -## to check the correct transmission of the auto-increment options to -## other nodes: -## - -SET SESSION binlog_format='ROW'; - -show variables like 'binlog_format'; - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - ---connection node_1 - -## -## Verify the return to automatic calculation of the step -## and offset of the auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -show variables like 'binlog_format'; -show variables like '%auto_increment%'; - -## -## Verify the recovery of original user-defined values after -## stopping the automatic control over auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -show variables like '%auto_increment%'; - -## -## Restore original options and drop test table: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -drop table t1; - ---source include/auto_increment_offset_restore.inc diff --git a/sql/field.h b/sql/field.h index 30b4b9fd68e..c21bba6936f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1329,17 +1329,6 @@ public: /* Hash value */ virtual void hash(ulong *nr, ulong *nr2); - /** - Get the upper limit of the MySQL integral and floating-point type. - - @return maximum allowed value for the field - */ - virtual ulonglong get_max_int_value() const - { - DBUG_ASSERT(false); - return 0ULL; - } - /** Checks whether a string field is part of write_set. @@ -1807,11 +1796,6 @@ public: *to= *from; return from + 1; } - - virtual ulonglong get_max_int_value() const - { - return unsigned_flag ? 0xFFULL : 0x7FULL; - } }; @@ -1853,10 +1837,6 @@ public: virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data) { return unpack_int16(to, from, from_end); } - virtual ulonglong get_max_int_value() const - { - return unsigned_flag ? 0xFFFFULL : 0x7FFFULL; - } }; class Field_medium :public Field_num { @@ -1890,10 +1870,6 @@ public: { return Field::pack(to, from, max_length); } - virtual ulonglong get_max_int_value() const - { - return unsigned_flag ? 0xFFFFFFULL : 0x7FFFFFULL; - } }; @@ -1939,10 +1915,6 @@ public: { return unpack_int32(to, from, from_end); } - virtual ulonglong get_max_int_value() const - { - return unsigned_flag ? 0xFFFFFFFFULL : 0x7FFFFFFFULL; - } }; @@ -1992,10 +1964,6 @@ public: { return unpack_int64(to, from, from_end); } - virtual ulonglong get_max_int_value() const - { - return unsigned_flag ? 0xFFFFFFFFFFFFFFFFULL : 0x7FFFFFFFFFFFFFFFULL; - } }; @@ -2029,13 +1997,6 @@ public: uint32 pack_length() const { return sizeof(float); } uint row_pack_length() const { return pack_length(); } void sql_type(String &str) const; - virtual ulonglong get_max_int_value() const - { - /* - We use the maximum as per IEEE754-2008 standard, 2^24 - */ - return 0x1000000ULL; - } private: int do_save_field_metadata(uchar *first_byte); }; @@ -2078,13 +2039,6 @@ public: uint32 pack_length() const { return sizeof(double); } uint row_pack_length() const { return pack_length(); } void sql_type(String &str) const; - virtual ulonglong get_max_int_value() const - { - /* - We use the maximum as per IEEE754-2008 standard, 2^53 - */ - return 0x20000000000000ULL; - } private: int do_save_field_metadata(uchar *first_byte); }; diff --git a/sql/handler.cc b/sql/handler.cc index e2690023807..9c319b995da 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2853,15 +2853,9 @@ compute_next_insert_id(ulonglong nr,struct system_variables *variables) nr= nr + 1; // optimization of the formula below else { - /* - Calculating the number of complete auto_increment_increment extents: - */ nr= (((nr+ variables->auto_increment_increment - variables->auto_increment_offset)) / (ulonglong) variables->auto_increment_increment); - /* - Adding an offset to the auto_increment_increment extent boundary: - */ nr= (nr* (ulonglong) variables->auto_increment_increment + variables->auto_increment_offset); } @@ -2917,14 +2911,8 @@ prev_insert_id(ulonglong nr, struct system_variables *variables) } if (variables->auto_increment_increment == 1) return nr; // optimization of the formula below - /* - Calculating the number of complete auto_increment_increment extents: - */ nr= (((nr - variables->auto_increment_offset)) / (ulonglong) variables->auto_increment_increment); - /* - Adding an offset to the auto_increment_increment extent boundary: - */ return (nr * (ulonglong) variables->auto_increment_increment + variables->auto_increment_offset); } @@ -3146,23 +3134,10 @@ int handler::update_auto_increment() if (unlikely(tmp)) // Out of range value in store { /* - first test if the query was aborted due to strict mode constraints + It's better to return an error here than getting a confusing + 'duplicate key error' later. */ - if (thd->killed == KILL_BAD_DATA || - nr > table->next_number_field->get_max_int_value()) - DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); - - /* - field refused this value (overflow) and truncated it, use the result of - the truncation (which is going to be inserted); however we try to - decrease it to honour auto_increment_* variables. - That will shift the left bound of the reserved interval, we don't - bother shifting the right bound (anyway any other value from this - interval will cause a duplicate key). - */ - nr= prev_insert_id(table->next_number_field->val_int(), variables); - if (unlikely(table->next_number_field->store((longlong) nr, TRUE))) - nr= table->next_number_field->val_int(); + result= HA_ERR_AUTOINC_ERANGE; } if (append) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a65f430f74e..34bb75cbfba 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4192,20 +4192,6 @@ static int init_common_variables() DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, server_version, SYSTEM_TYPE,MACHINE_TYPE)); -#ifdef WITH_WSREP - /* - We need to initialize auxiliary variables, that will be - further keep the original values of auto-increment options - as they set by the user. These variables used to restore - user-defined values of the auto-increment options after - setting of the wsrep_auto_increment_control to 'OFF'. - */ - global_system_variables.saved_auto_increment_increment= - global_system_variables.auto_increment_increment; - global_system_variables.saved_auto_increment_offset= - global_system_variables.auto_increment_offset; -#endif /* WITH_WSREP */ - #ifdef HAVE_LARGE_PAGES /* Initialize large page size */ if (opt_large_pages) diff --git a/sql/sql_class.h b/sql/sql_class.h index f0c486bd172..53e451511d5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -552,17 +552,6 @@ typedef struct system_variables ha_rows max_join_size; ha_rows expensive_subquery_limit; ulong auto_increment_increment, auto_increment_offset; -#ifdef WITH_WSREP - /* - Variables with stored values of the auto_increment_increment - and auto_increment_offset options that are will be needed when - wsrep_auto_increment_control will be set to 'OFF', because the - setting it to 'ON' leads to overwriting of the original values - (which are set by the user) by calculated values (which are - based on the cluster's size): - */ - ulong saved_auto_increment_increment, saved_auto_increment_offset; -#endif /* WITH_WSREP */ ulong lock_wait_timeout; ulong join_cache_level; ulong max_allowed_packet; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 8a67c1d38f3..f941794f89e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -345,56 +345,13 @@ static Sys_var_long Sys_pfs_connect_attrs_size( #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ -#ifdef WITH_WSREP - -/* - We need to keep the original values set by the user, as they will - be lost if wsrep_auto_increment_control set to 'ON': -*/ -static bool update_auto_increment_increment (sys_var *self, THD *thd, enum_var_type type) -{ - if (type == OPT_GLOBAL) - global_system_variables.saved_auto_increment_increment= - global_system_variables.auto_increment_increment; - else - thd->variables.saved_auto_increment_increment= - thd->variables.auto_increment_increment; - return false; -} - -#endif /* WITH_WSREP */ - static Sys_var_ulong Sys_auto_increment_increment( "auto_increment_increment", "Auto-increment columns are incremented by this", SESSION_VAR(auto_increment_increment), CMD_LINE(OPT_ARG), VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1), -#ifdef WITH_WSREP - NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), - ON_UPDATE(update_auto_increment_increment)); -#else NO_MUTEX_GUARD, IN_BINLOG); -#endif /* WITH_WSREP */ - -#ifdef WITH_WSREP - -/* - We need to keep the original values set by the user, as they will - be lost if wsrep_auto_increment_control set to 'ON': -*/ -static bool update_auto_increment_offset (sys_var *self, THD *thd, enum_var_type type) -{ - if (type == OPT_GLOBAL) - global_system_variables.saved_auto_increment_offset= - global_system_variables.auto_increment_offset; - else - thd->variables.saved_auto_increment_offset= - thd->variables.auto_increment_offset; - return false; -} - -#endif /* WITH_WSREP */ static Sys_var_ulong Sys_auto_increment_offset( "auto_increment_offset", @@ -403,12 +360,7 @@ static Sys_var_ulong Sys_auto_increment_offset( SESSION_VAR(auto_increment_offset), CMD_LINE(OPT_ARG), VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1), -#ifdef WITH_WSREP - NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), - ON_UPDATE(update_auto_increment_offset)); -#else NO_MUTEX_GUARD, IN_BINLOG); -#endif /* WITH_WSREP */ static Sys_var_mybool Sys_automatic_sp_privileges( "automatic_sp_privileges", @@ -4895,54 +4847,11 @@ static Sys_var_ulong Sys_wsrep_retry_autocommit( SESSION_VAR(wsrep_retry_autocommit), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 10000), DEFAULT(1), BLOCK_SIZE(1)); -static bool update_wsrep_auto_increment_control (sys_var *self, THD *thd, enum_var_type type) -{ - if (wsrep_auto_increment_control) - { - /* - The variables that control auto increment shall be calculated - automaticaly based on the size of the cluster. This usually done - within the wsrep_view_handler_cb callback. However, if the user - manually sets the value of wsrep_auto_increment_control to 'ON', - then we should to re-calculate these variables again (because - these values may be required before wsrep_view_handler_cb will - be re-invoked, which is rarely invoked if the cluster stays in - the stable state): - */ - global_system_variables.auto_increment_increment= - wsrep_cluster_size ? wsrep_cluster_size : 1; - global_system_variables.auto_increment_offset= - wsrep_local_index >= 0 ? wsrep_local_index + 1 : 1; - thd->variables.auto_increment_increment= - global_system_variables.auto_increment_increment; - thd->variables.auto_increment_offset= - global_system_variables.auto_increment_offset; - } - else - { - /* - We must restore the last values of the variables that - are explicitly specified by the user: - */ - global_system_variables.auto_increment_increment= - global_system_variables.saved_auto_increment_increment; - global_system_variables.auto_increment_offset= - global_system_variables.saved_auto_increment_offset; - thd->variables.auto_increment_increment= - thd->variables.saved_auto_increment_increment; - thd->variables.auto_increment_offset= - thd->variables.saved_auto_increment_offset; - } - return false; -} - static Sys_var_mybool Sys_wsrep_auto_increment_control( "wsrep_auto_increment_control", "To automatically control the " "assignment of autoincrement variables", GLOBAL_VAR(wsrep_auto_increment_control), - CMD_LINE(OPT_ARG), DEFAULT(TRUE), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), - ON_UPDATE(update_wsrep_auto_increment_control)); + CMD_LINE(OPT_ARG), DEFAULT(TRUE)); static Sys_var_mybool Sys_wsrep_drupal_282555_workaround( "wsrep_drupal_282555_workaround", "Enable a workaround to handle the " diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index c015f94e165..9fc8aa02df4 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -162,10 +162,6 @@ extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd); extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id); extern "C" void wsrep_set_data_home_dir(const char *data_dir); -extern "C" void wsrep_thd_auto_increment_variables(THD*, - unsigned long long *offset, - unsigned long long *increment); - extern void wsrep_close_client_connections(my_bool wait_to_end); extern int wsrep_wait_committing_connections_close(int wait_time); extern void wsrep_close_applier(THD *thd); diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index cd7359160d6..eb26da61282 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -676,25 +676,3 @@ bool wsrep_thd_has_explicit_locks(THD *thd) assert(thd); return thd->mdl_context.has_explicit_locks(); } - -/* - Get auto increment variables for THD. Use global settings for - applier threads. - */ -extern "C" -void wsrep_thd_auto_increment_variables(THD* thd, - unsigned long long* offset, - unsigned long long* increment) -{ - if (thd->wsrep_exec_mode == REPL_RECV && - thd->wsrep_conflict_state != REPLAYING) - { - *offset= global_system_variables.auto_increment_offset; - *increment= global_system_variables.auto_increment_increment; - } - else - { - *offset= thd->variables.auto_increment_offset; - *increment= thd->variables.auto_increment_increment; - } -} diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d134d157945..d2701ecfc0b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8402,29 +8402,14 @@ set_max_autoinc: /* This should filter out the negative values set explicitly by the user. */ if (auto_inc <= col_max_value) { + ut_a(prebuilt->autoinc_increment > 0); + ulonglong offset; ulonglong increment; dberr_t err; -#ifdef WITH_WSREP - /* Applier threads which are - processing ROW events and don't go - through server level autoinc - processing, therefore m_prebuilt - autoinc values don't get - properly assigned. Fetch values from - server side. */ - if (wsrep_on(current_thd) && - wsrep_thd_exec_mode(current_thd) == REPL_RECV) { - wsrep_thd_auto_increment_variables(current_thd, &offset, &increment); - } else { -#endif /* WITH_WSREP */ - ut_a(prebuilt->autoinc_increment > 0); - offset = prebuilt->autoinc_offset; - increment = prebuilt->autoinc_increment; -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ + offset = prebuilt->autoinc_offset; + increment = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( auto_inc, @@ -8939,32 +8924,16 @@ ha_innobase::update_row( /* We need the upper limit of the col type to check for whether we update the table autoinc counter or not. */ - col_max_value = - table->next_number_field->get_max_int_value(); + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); if (auto_inc <= col_max_value && auto_inc != 0) { ulonglong offset; ulonglong increment; -#ifdef WITH_WSREP - /* Applier threads which are processing - ROW events and don't go through server - level autoinc processing, therefore - m_prebuilt autoinc values don't get - properly assigned. Fetch values from - server side. */ - if (wsrep_on(current_thd) && - wsrep_thd_exec_mode(current_thd) == REPL_RECV) { - wsrep_thd_auto_increment_variables( - current_thd, &offset, &increment); - } else { -#endif /* WITH_WSREP */ - offset = prebuilt->autoinc_offset; - increment = prebuilt->autoinc_increment; -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ + offset = prebuilt->autoinc_offset; + increment = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( auto_inc, 1, increment, offset, col_max_value); @@ -16075,14 +16044,14 @@ ha_innobase::get_auto_increment( increment, thd_get_thread_id(ha_thd()), current, autoinc); - - if (!wsrep_on(ha_thd())) { - current = autoinc - prebuilt->autoinc_increment; - - current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); + if (!wsrep_on(ha_thd())) + { + current = autoinc - prebuilt->autoinc_increment; } + current = innobase_next_autoinc( + current, 1, increment, offset, col_max_value); + dict_table_autoinc_initialize(prebuilt->table, current); *first_value = current; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 857fc7e66f1..3cd7cb6977b 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -8988,25 +8988,8 @@ set_max_autoinc: ulonglong increment; dberr_t err; -#ifdef WITH_WSREP - /* Applier threads which are - processing ROW events and don't go - through server level autoinc - processing, therefore m_prebuilt - autoinc values don't get - properly assigned. Fetch values from - server side. */ - if (wsrep_on(current_thd) && - wsrep_thd_exec_mode(current_thd) == REPL_RECV) { - wsrep_thd_auto_increment_variables(current_thd, &offset, &increment); - } else { -#endif /* WITH_WSREP */ - ut_a(prebuilt->autoinc_increment > 0); - offset = prebuilt->autoinc_offset; - increment = prebuilt->autoinc_increment; -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ + offset = prebuilt->autoinc_offset; + increment = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( auto_inc, @@ -9519,32 +9502,16 @@ ha_innobase::update_row( /* We need the upper limit of the col type to check for whether we update the table autoinc counter or not. */ - col_max_value = - table->next_number_field->get_max_int_value(); + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); if (auto_inc <= col_max_value && auto_inc != 0) { ulonglong offset; ulonglong increment; -#ifdef WITH_WSREP - /* Applier threads which are processing - ROW events and don't go through server - level autoinc processing, therefore - m_prebuilt autoinc values don't get - properly assigned. Fetch values from - server side. */ - if (wsrep_on(current_thd) && - wsrep_thd_exec_mode(current_thd) == REPL_RECV) { - wsrep_thd_auto_increment_variables( - current_thd, &offset, &increment); - } else { -#endif /* WITH_WSREP */ - offset = prebuilt->autoinc_offset; - increment = prebuilt->autoinc_increment; -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ + offset = prebuilt->autoinc_offset; + increment = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( auto_inc, 1, increment, offset, col_max_value); @@ -16775,14 +16742,14 @@ ha_innobase::get_auto_increment( increment, thd_get_thread_id(ha_thd()), current, autoinc); - - if (!wsrep_on(ha_thd())) { - current = autoinc - prebuilt->autoinc_increment; - - current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); + if (!wsrep_on(ha_thd())) + { + current = autoinc - prebuilt->autoinc_increment; } + current = innobase_next_autoinc( + current, 1, increment, offset, col_max_value); + dict_table_autoinc_initialize(prebuilt->table, current); *first_value = current; From f693170c75a1f39f3f06aca683fe4a1998785008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 31 Aug 2018 13:16:31 +0300 Subject: [PATCH 13/13] MDEV-16647 InnoDB fails to drop large temporary table on disconnect This regression was introduced in MDEV-16515. We would fail to drop a temporary table on client disconnect, because trx_is_interrupted() would hold. To add insult to injury, in MariaDB 10.1, InnoDB temporary tables are actually persistent, so the garbage temporary tables will never be dropped. row_drop_table_for_mysql(): If several iterations of buf_LRU_drop_page_hash_for_tablespace() are needed, do not interrupt dropping a temporary table even after the transaction was marked as killed. Server shutdown will still terminate the loop, and also DROP TABLE of persistent tables will keep checking if the execution was aborted. --- storage/innobase/row/row0mysql.cc | 3 ++- storage/xtradb/row/row0mysql.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index c6e038448cd..abee3386039 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4222,7 +4222,8 @@ row_drop_table_for_mysql( hold the InnoDB dictionary lock, we will drop any adaptive hash index entries upfront. */ while (buf_LRU_drop_page_hash_for_tablespace(table)) { - if (trx_is_interrupted(trx) + if ((!dict_table_is_temporary(table) + && trx_is_interrupted(trx)) || srv_shutdown_state != SRV_SHUTDOWN_NONE) { err = DB_INTERRUPTED; goto funct_exit; diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index c9684d49167..e4a6cd39699 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -4233,7 +4233,8 @@ row_drop_table_for_mysql( hold the InnoDB dictionary lock, we will drop any adaptive hash index entries upfront. */ while (buf_LRU_drop_page_hash_for_tablespace(table)) { - if (trx_is_interrupted(trx) + if ((!dict_table_is_temporary(table) + && trx_is_interrupted(trx)) || srv_shutdown_state != SRV_SHUTDOWN_NONE) { err = DB_INTERRUPTED; goto funct_exit;