From 1ac4d0c168c3d438752e3a72c79d29a6cbd5a127 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 9 Apr 2021 17:38:21 +0530 Subject: [PATCH 01/15] BtrBulk::table_name(): Return the table name while displaying table name for fts diagnostics --- storage/innobase/include/btr0bulk.h | 2 +- storage/innobase/row/row0ftsort.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h index 6687d29593a..911a2726422 100644 --- a/storage/innobase/include/btr0bulk.h +++ b/storage/innobase/include/btr0bulk.h @@ -326,7 +326,7 @@ public: /** Re-latch all latches */ void latch(); - dict_index_t* index() { return m_index; } + table_name_t table_name() { return m_index->table->name; } private: /** Insert a tuple to a page in a level diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 39b31c153ad..2ca930e0934 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1221,7 +1221,7 @@ row_merge_write_fts_word( if (UNIV_UNLIKELY(error != DB_SUCCESS)) { ib::error() << "Failed to write word to FTS auxiliary" " index table " - << ins_ctx->btr_bulk->index()->table->name + << ins_ctx->btr_bulk->table_name() << ", error " << error; ret = error; } From 8ff0ac45dcc909688c50d93f7575e2084433df30 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 7 Apr 2021 16:44:30 +0200 Subject: [PATCH 02/15] MDEV-25328: --innodb command line option causes mariabackup to fail This patch fixes an issue with launching mariabackup during SST (when used with Galera), when during bootstrap mariabackup receives the "--innodb" option, which is incorrectly interpreted as shortcut for "--innodb-force-recovery". This patch does not require separate test for mtr, as the problem is visible in general testing on buildbot. --- extra/mariabackup/xtrabackup.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 59551a7d044..0743c8224b0 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -6622,6 +6622,8 @@ int main(int argc, char **argv) { char **client_defaults, **server_defaults; + my_getopt_prefix_matching= 0; + if (get_exepath(mariabackup_exe,FN_REFLEN, argv[0])) strncpy(mariabackup_exe,argv[0], FN_REFLEN-1); From d5dacca4c5a631b81426c8ca559a54c97487fcbb Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 7 Apr 2021 16:49:10 +0200 Subject: [PATCH 03/15] Clarified abbreviated option names in some tests, to avoid problems with ambiguous options in the future. --- mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test | 2 +- mysql-test/t/mysqldump-nl.test | 8 ++++---- mysql-test/t/parser_not_embedded.test | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test b/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test index 5bdd1ff8b6b..a594b7c2a61 100644 --- a/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test +++ b/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test @@ -329,7 +329,7 @@ while($ntables) -- echo ### detect failure. Before the patch mysqlbinlog would find -- echo ### a corrupted event, thence would fail. -- let $MYSQLD_DATADIR= `SELECT @@datadir` --- exec $MYSQL_BINLOG -v --hex $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog +-- exec $MYSQL_BINLOG -v --hexdump $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog ## clean up ## For debugging purposes you might want not to remove these diff --git a/mysql-test/t/mysqldump-nl.test b/mysql-test/t/mysqldump-nl.test index 863c846b9a6..4451b0605c2 100644 --- a/mysql-test/t/mysqldump-nl.test +++ b/mysql-test/t/mysqldump-nl.test @@ -26,10 +26,10 @@ create procedure sp() select * from `v1 flush tables; use test; -exec $MYSQL_DUMP --compact --comment --routines --add-drop-database --databases 'mysqltest1 +exec $MYSQL_DUMP --compact --comments --routines --add-drop-database --databases 'mysqltest1 1tsetlqsym'; -exec $MYSQL_DUMP --compact --comment --routines --add-drop-database --databases 'mysqltest1 +exec $MYSQL_DUMP --compact --comments --routines --add-drop-database --databases 'mysqltest1 1tsetlqsym' | $MYSQL; show tables from `mysqltest1 @@ -45,11 +45,11 @@ create database `test\`` show databases like 'test%'; -exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\` +exec $MYSQL_DUMP --compact --comments --add-drop-database --databases 'test`' 'test\` \! ls #'; -exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\` +exec $MYSQL_DUMP --compact --comments --add-drop-database --databases 'test`' 'test\` \! ls #' | $MYSQL; diff --git a/mysql-test/t/parser_not_embedded.test b/mysql-test/t/parser_not_embedded.test index 3ebd23e888e..3af1260f4ad 100644 --- a/mysql-test/t/parser_not_embedded.test +++ b/mysql-test/t/parser_not_embedded.test @@ -21,7 +21,7 @@ select 7 as expected, /*!01000 1 + /*!01000 8 + /*!01000 error */ 16 + */ 2 + */ select 4 as expected, /* 1 + /*!01000 8 + */ 2 + */ 4; EOF ---exec $MYSQL --comment --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql +--exec $MYSQL --comments --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql --remove_file $MYSQLTEST_VARDIR/tmp/bug39559.sql --echo # Bug#46527 "COMMIT AND CHAIN RELEASE does not make sense" From bf1e09e0c472600165887b6ad52b993a00394f5a Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 7 Apr 2021 16:53:23 +0200 Subject: [PATCH 04/15] Removed extra spaces in generated command lines (minor "cosmetic" change after MDEV-24197) --- extra/mariabackup/xtrabackup.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 0743c8224b0..d4e7114f635 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1815,33 +1815,33 @@ static int prepare_export() // Process defaults-file , it can have some --lc-language stuff, // which is* unfortunately* still necessary to get mysqld up - if (strncmp(orig_argv1,"--defaults-file=",16) == 0) + if (strncmp(orig_argv1,"--defaults-file=", 16) == 0) { snprintf(cmdline, sizeof cmdline, - IF_WIN("\"","") "\"%s\" --mysqld \"%s\" " + IF_WIN("\"","") "\"%s\" --mysqld \"%s\"" " --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=." " --innodb --innodb-fast-shutdown=0 --loose-partition" " --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu" - " --console --skip-log-error --skip-log-bin --bootstrap %s < " + " --console --skip-log-error --skip-log-bin --bootstrap %s< " BOOTSTRAP_FILENAME IF_WIN("\"",""), mariabackup_exe, orig_argv1, (my_defaults_group_suffix?my_defaults_group_suffix:""), xtrabackup_use_memory, - (srv_force_recovery ? "--innodb-force-recovery=1" : "")); + (srv_force_recovery ? "--innodb-force-recovery=1 " : "")); } else { snprintf(cmdline, sizeof cmdline, - IF_WIN("\"","") "\"%s\" --mysqld" + IF_WIN("\"","") "\"%s\" --mysqld" " --defaults-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=." " --innodb --innodb-fast-shutdown=0 --loose-partition" " --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu" - " --console --log-error= --skip-log-bin --bootstrap %s < " + " --console --log-error= --skip-log-bin --bootstrap %s< " BOOTSTRAP_FILENAME IF_WIN("\"",""), mariabackup_exe, (my_defaults_group_suffix?my_defaults_group_suffix:""), xtrabackup_use_memory, - (srv_force_recovery ? "--innodb-force-recovery=1" : "")); + (srv_force_recovery ? "--innodb-force-recovery=1 " : "")); } msg("Prepare export : executing %s\n", cmdline); From 3eecb8db227173284aff8c457dea3c8009117a72 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Sun, 11 Apr 2021 17:07:36 +0200 Subject: [PATCH 05/15] MDEV-25356: SST scripts should use the new mariabackup interface SST scripts for Galera should use the new mariabackup interface instead of the innobackupex interface, which is currently only supported for compatibility reasons. This commit converts the SST script for mariabackup to use the new interface. It does not need separate tests, as any problems will be seen as failures when running multiple tests for the mariabackup-based SST. --- extra/mariabackup/backup_mysql.cc | 8 ++++++++ extra/mariabackup/innobackupex.cc | 7 ------- scripts/wsrep_sst_mariabackup.sh | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 1d7242c5c75..824b8b6d5f3 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -44,6 +44,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #include #include #include +#include #include #include #include "common.h" @@ -107,6 +108,13 @@ xb_mysql_connect() return(NULL); } +#if !defined(DONT_USE_MYSQL_PWD) + if (!opt_password) + { + opt_password=getenv("MYSQL_PWD"); + } +#endif + if (!opt_secure_auth) { mysql_options(connection, MYSQL_SECURE_AUTH, (char *) &opt_secure_auth); diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc index 5bc320264e4..fefd81dc1be 100644 --- a/extra/mariabackup/innobackupex.cc +++ b/extra/mariabackup/innobackupex.cc @@ -41,7 +41,6 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #include #include -#include #include #include #include @@ -905,12 +904,6 @@ ibx_init() opt_user = opt_ibx_user; opt_password = opt_ibx_password; -#if !defined(DONT_USE_MYSQL_PWD) - if (!opt_password) - { - opt_password=getenv("MYSQL_PWD"); - } -#endif opt_host = opt_ibx_host; opt_defaults_group = opt_ibx_defaults_group; opt_socket = opt_ibx_socket; diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 4354e341ca5..29c527d8ff3 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -766,9 +766,9 @@ if [[ $ssyslog -eq 1 ]];then logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@" } - INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply" - INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move" - INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" + INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply" + INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --move-back $disver $impts --force-non-empty-directories --target-dir=\${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move" + INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --backup $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt --target-dir=\$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" fi else @@ -830,9 +830,9 @@ then fi - INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} &> ${INNOAPPLYLOG}" - INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &> ${INNOMOVELOG}" - INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> ${INNOBACKUPLOG}" + INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} &> ${INNOAPPLYLOG}" + INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --move-back $disver $impts --force-non-empty-directories --target-dir=\${DATA} &> ${INNOMOVELOG}" + INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --backup $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt --target-dir=\$itmpdir 2> ${INNOBACKUPLOG}" fi get_stream @@ -855,7 +855,7 @@ then -z $(parse_cnf --mysqld tmpdir "") && \ -z $(parse_cnf xtrabackup tmpdir "") ]]; then xtmpdir=$(mktemp -d) - tmpopts=" --tmpdir=$xtmpdir" + tmpopts="--tmpdir=$xtmpdir" wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory" fi From 966c5a35af0a84ea147f754f6eb0cc1fd0a5826f Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 1 Apr 2021 07:01:11 +0200 Subject: [PATCH 06/15] MDEV-25307: The value of the auto-increment variables changes during the test The auto-increment variables may change intermittently during the execution of some tests from the Galera mtr suite, causing these tests to fail. This patch creates conditions in which unpredictable changes to these variables are not possible during the execution of those tests in which this problem is noticed or their values are restored before the end of testing. --- mysql-test/suite/galera/disabled.def | 1 - mysql-test/suite/galera/r/galera_var_sst_auth.result | 2 ++ mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf | 7 +++++++ mysql-test/suite/galera/t/galera_var_sst_auth.cnf | 5 ----- mysql-test/suite/galera/t/galera_var_sst_auth.test | 8 +++++++- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index a72c84564f0..6285da7b11c 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -14,7 +14,6 @@ MW-328A : MDEV-22666 galera.MW-328A MTR failed: "Semaphore wait has lasted > 600 MW-328B : MDEV-22666 galera.MW-328A MTR failed: "Semaphore wait has lasted > 600 seconds" and do not release port 16002 MW-329 : MDEV-19962 Galera test failure on MW-329 galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() -galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc galera_concurrent_ctas : MDEV-24842 Galera test failure on galera_concurrent_ctas galera_gcache_recover_manytrx : MDEV-18834 Galera test failure galera_mdl_race : MDEV-21524: galera.galera_mdl_race MTR failed: query 'reap' succeeded - should have failed with errno 1213 diff --git a/mysql-test/suite/galera/r/galera_var_sst_auth.result b/mysql-test/suite/galera/r/galera_var_sst_auth.result index 89a27dce4f6..e03576175c5 100644 --- a/mysql-test/suite/galera/r/galera_var_sst_auth.result +++ b/mysql-test/suite/galera/r/galera_var_sst_auth.result @@ -1,3 +1,5 @@ +connection node_1; +connection node_2; SELECT @@global.wsrep_sst_auth; @@global.wsrep_sst_auth ******** diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf new file mode 100644 index 00000000000..889c81b4a0a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +auto_increment_offset=1 + +[mysqld.2] +auto_increment_offset=2 diff --git a/mysql-test/suite/galera/t/galera_var_sst_auth.cnf b/mysql-test/suite/galera/t/galera_var_sst_auth.cnf index ff29db2306b..114815d446a 100644 --- a/mysql-test/suite/galera/t/galera_var_sst_auth.cnf +++ b/mysql-test/suite/galera/t/galera_var_sst_auth.cnf @@ -5,8 +5,3 @@ wsrep_sst_auth=root: [mysqld.2] wsrep_sst_auth=root: - - - - - diff --git a/mysql-test/suite/galera/t/galera_var_sst_auth.test b/mysql-test/suite/galera/t/galera_var_sst_auth.test index ad7f46620ad..ebeaddc0e63 100644 --- a/mysql-test/suite/galera/t/galera_var_sst_auth.test +++ b/mysql-test/suite/galera/t/galera_var_sst_auth.test @@ -1,6 +1,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # # MDEV-10492: Assertion failure on shutdown when wsrep_sst_auth set in config # @@ -30,4 +35,5 @@ SELECT @@global.wsrep_sst_auth; --source include/wait_condition.inc SELECT @@global.wsrep_sst_auth; - +# Restore original auto_increment_offset values. +--source include/auto_increment_offset_restore.inc From 058d93d47af79e650dc6a7abc107a400d8598e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 11 Apr 2021 22:05:52 -0700 Subject: [PATCH 07/15] Deb: Stop depending on empty transitional package dh-systemd MariaDB Server still supports Ubuntu 16.04 "Xenial" until it goes EOL in April 30, 2021. Thus we need to include a customization for backwards compatibility. This change is intended to be applied for all MariaDB versions still supported, i.e. 10.2 to 10.6. --- debian/autobake-deb.sh | 9 +++++++++ debian/control | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 5cf2398575a..21ab4d8fe22 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -106,6 +106,15 @@ then sed '/Package: mariadb-plugin-cassandra/,/^$/d' -i debian/control fi +# From Debian Stretch/Ubuntu Bionic onwards dh-systemd is just an empty +# transitional metapackage and the functionality was merged into debhelper. +# In Ubuntu Hirsute is was completely removed, so it can't be referenced anymore. +# Keep using it only on Debian Jessie and Ubuntu Xenial. +if apt-cache madison dh-systemd | grep 'dh-systemd' >/dev/null 2>&1 +then + sed 's/debhelper (>= 9.20160709~),/debhelper (>= 9), dh-systemd,/' -i debian/control +fi + # Adjust changelog, add new version echo "Incrementing changelog and starting build scripts" diff --git a/debian/control b/debian/control index ba6243c38dd..c906c1bd505 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: MariaDB Developers Build-Depends: bison, chrpath, cmake (>= 2.7), - debhelper (>= 9), + debhelper (>= 9.20160709~), dh-apparmor, dh-systemd, dpatch, From 75dd7a048315affc0c5986b6e955965d46621c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Apr 2021 10:53:08 +0300 Subject: [PATCH 08/15] MDEV-24434 Assertion trx->in_rw_trx_list... in trx_sys_any_active_transactions() trx_sys_any_active_transactions(): Remove a bogus debug assertion. In trx_commit_in_memory() and trx_erase_lists(), we will remove the transaction from trx_sys->rw_trx_list and set the state to TRX_STATE_COMMITTED_IN_MEMORY. --- storage/innobase/trx/trx0sys.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 8d00bd824a2..9138e9475bf 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -997,11 +997,6 @@ trx_sys_any_active_transactions(void) /* This may count some ACTIVE transactions twice, both in rw_trx_list and mysql_trx_list. */ total_trx += trx->state == TRX_STATE_ACTIVE; - /* Any PREPARED or COMMITTED transactions must be - in rw_trx_list, so it suffices to count them there. */ - ut_ad(trx->in_rw_trx_list - || trx->state == TRX_STATE_NOT_STARTED - || trx->state == TRX_STATE_ACTIVE); trx_mutex_exit(trx); } From ea2d44d01b4aead2e1d6d88b9eede39fd99dff67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Apr 2021 11:29:32 +0300 Subject: [PATCH 09/15] MDEV-18802 Assertion table->stat_initialized failed in dict_stats_update_if_needed() When a table has been evicted from dict_sys and reloaded internally by InnoDB for FOREIGN KEY processing, statistics may not be initialized, but nevertheless row_update_cascade_for_mysql() could invoke dict_stats_update_if_needed(). In that case, we cannot really update the statistics. For tables that have STATS_PERSISTENT=1 and STATS_AUTO_RECALC=1, ANALYZE TABLE might have to be executed later. dict_stats_update_if_needed(): Replace the assertion with a conditional early return. --- storage/innobase/dict/dict0stats_bg.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 589f53dde38..a4619a6069b 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -154,9 +154,24 @@ schedule new estimates for table and index statistics to be calculated. void dict_stats_update_if_needed_func(dict_table_t *table) #endif { - ut_ad(table->stat_initialized); ut_ad(!mutex_own(&dict_sys->mutex)); + if (UNIV_UNLIKELY(!table->stat_initialized)) { + /* The table may have been evicted from dict_sys + and reloaded internally by InnoDB for FOREIGN KEY + processing, but not reloaded by the SQL layer. + + We can (re)compute the transient statistics when the + table is actually loaded by the SQL layer. + + Note: If InnoDB persistent statistics are enabled, + we will skip the updates. We must do this, because + dict_table_get_n_rows() below assumes that the + statistics have been initialized. The DBA may have + to execute ANALYZE TABLE. */ + return; + } + ulonglong counter = table->stat_modified_counter++; ulonglong n_rows = dict_table_get_n_rows(table); From cf2c6b7f8db9413e7c5e31e87bb5c799253d8d2e Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 9 Apr 2021 21:30:43 +0530 Subject: [PATCH 10/15] MDEV-24971 InnoDB access freed virtual column after rollback of secondary index Problem: ======== InnoDB fails to clean the index stub if it fails to add the virtual index which contains new virtual column. But it clears the newly virtual column from index in clear_added_indexes() during inplace_alter_table. On commit, InnoDB evicts and reload the table. In case of rollback, it doesn't happen. InnoDB clears the ABORTED index while opening the table or doing the DDL. In the mean time, InnoDB can access the dropped virtual index columns while creating prebuilt or rollback of concurrent DML. Solution: ========== (1) InnoDB should maintain newly added virtual column while rollbacking the newly added virtual index. (2) InnoDB must not defer the index removal if the alter table is executed with LOCK=EXCLUSIVE. (3) For LOCK=SHARED, InnoDB should check whether the table has any other transaction lock other than alter transaction before deferring the index stub. Replaced has_new_v_col with dict_add_vcol_info in dict_index_t to indicate whether the index has any new virtual column. dict_index_t::has_new_v_col(): Returns whether the index has newly added virtual column, it doesn't say which columns are newly added virtual column ha_innobase_inplace_ctx::is_new_vcol(): Return whether the given column is added as a part of the current alter. ha_innobase_inplace_ctx::clean_new_vcol_index(): Copy the newly added virtual column to new_vcol_info in dict_index_t. Replace the column in the index fields with virtual column stored in new_vcol_info. dict_index_t::assign_new_v_col(): Store the number of virtual column added in index as a part of alter table. dict_index_t::get_n_new_vcol(): Get the number of newly added virtual column dict_index_t::assign_drop_v_col(): Allocate the memory for adding new virtual column in new_vcol_info. dict_index_t::add_drop_v_col(): Add the newly added virtual column in new_vcol_info. dict_table_t::has_lock_for_other_trx(): Whether the table has any other transaction lock than given transaction. row_merge_drop_indexes(): Add parameter alter_trx and check whether the table has any other lock than alter transaction. --- .../suite/gcol/r/virtual_index_drop.result | 69 ++++++++++++++++ .../suite/gcol/t/virtual_index_drop.test | 71 ++++++++++++++++ storage/innobase/dict/dict0dict.cc | 2 +- storage/innobase/dict/dict0mem.cc | 2 +- storage/innobase/handler/handler0alter.cc | 75 ++++++++++++----- storage/innobase/include/dict0mem.h | 81 +++++++++++++++++-- storage/innobase/include/row0merge.h | 20 ++--- storage/innobase/row/row0merge.cc | 29 ++++--- storage/innobase/row/row0purge.cc | 2 +- 9 files changed, 300 insertions(+), 51 deletions(-) create mode 100644 mysql-test/suite/gcol/r/virtual_index_drop.result create mode 100644 mysql-test/suite/gcol/t/virtual_index_drop.test diff --git a/mysql-test/suite/gcol/r/virtual_index_drop.result b/mysql-test/suite/gcol/r/virtual_index_drop.result new file mode 100644 index 00000000000..012e61be459 --- /dev/null +++ b/mysql-test/suite/gcol/r/virtual_index_drop.result @@ -0,0 +1,69 @@ +# +# MDEV-24971 InnoDB access freed virtual column +# after rollback of secondary index +# +CREATE TABLE t1(f1 INT, f2 INT AS (f1 + 2) VIRTUAL)ENGINE=InnoDB; +INSERT INTO t1(f1) VALUES(1), (1); +ALTER TABLE t1 ADD UNIQUE INDEX(f2), ALGORITHM=INPLACE, LOCK=EXCLUSIVE; +ERROR 23000: Duplicate entry '3' for key 'f2' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL, + `f2` int(11) GENERATED ALWAYS AS (`f1` + 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT AS (f1 + 2) VIRTUAL)ENGINE=InnoDB; +INSERT INTO t1(f1) VALUES(1), (1); +ALTER TABLE t1 ADD UNIQUE INDEX(f2), ALGORITHM=INPLACE, LOCK=SHARED; +ERROR 23000: Duplicate entry '3' for key 'f2' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL, + `f2` int(11) GENERATED ALWAYS AS (`f1` + 2) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB; +SET DEBUG_DBUG="+d,create_index_fail"; +SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal"; +ALTER TABLE t1 ADD COLUMN f3 INT AS (f1) VIRTUAL, ADD INDEX(f2, f3); +connect con1,localhost,root,,,; +SET DEBUG_SYNC="now WAIT_FOR con1_go"; +BEGIN; +SELECT * FROM t1; +f1 f2 +SET DEBUG_SYNC="now SIGNAL alter_signal"; +connection default; +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +connection con1; +rollback; +connection default; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL, + `f2` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB; +SET DEBUG_DBUG="+d,create_index_fail"; +SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal"; +ALTER TABLE t1 ADD INDEX(f2); +connection con1; +SET DEBUG_SYNC="now WAIT_FOR con1_go"; +BEGIN; +INSERT INTO t1(f1) VALUES(1); +SET DEBUG_SYNC="now SIGNAL alter_signal"; +connection default; +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +connection con1; +rollback; +connection default; +disconnect con1; +DROP TABLE t1; +CREATE TABLE t1(f1 CHAR(100), f2 CHAR(100) as (f1) VIRTUAL)ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN f3 CHAR(100) AS (f2) VIRTUAL, ADD INDEX(f3(10), f1, f3(12)); +ERROR 42S21: Duplicate column name 'f3' +DROP TABLE t1; +SET DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/gcol/t/virtual_index_drop.test b/mysql-test/suite/gcol/t/virtual_index_drop.test new file mode 100644 index 00000000000..016832b9e6d --- /dev/null +++ b/mysql-test/suite/gcol/t/virtual_index_drop.test @@ -0,0 +1,71 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--echo # +--echo # MDEV-24971 InnoDB access freed virtual column +--echo # after rollback of secondary index +--echo # + +# Exclusive lock must not defer the index removal + +CREATE TABLE t1(f1 INT, f2 INT AS (f1 + 2) VIRTUAL)ENGINE=InnoDB; +INSERT INTO t1(f1) VALUES(1), (1); +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX(f2), ALGORITHM=INPLACE, LOCK=EXCLUSIVE; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# If Shared lock and table doesn't have any other open handle +# then InnoDB must not defer the index removal + +CREATE TABLE t1(f1 INT, f2 INT AS (f1 + 2) VIRTUAL)ENGINE=InnoDB; +INSERT INTO t1(f1) VALUES(1), (1); +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX(f2), ALGORITHM=INPLACE, LOCK=SHARED; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# InnoDB should store the newly dropped virtual column into +# new_vcol_info in index when rollback of alter happens + +CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB; +SET DEBUG_DBUG="+d,create_index_fail"; +SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal"; +SEND ALTER TABLE t1 ADD COLUMN f3 INT AS (f1) VIRTUAL, ADD INDEX(f2, f3); +connect(con1,localhost,root,,,); +SET DEBUG_SYNC="now WAIT_FOR con1_go"; +BEGIN; +SELECT * FROM t1; +SET DEBUG_SYNC="now SIGNAL alter_signal"; +connection default; +--error ER_DUP_ENTRY +reap; +connection con1; +rollback; +connection default; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB; +SET DEBUG_DBUG="+d,create_index_fail"; +SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal"; +send ALTER TABLE t1 ADD INDEX(f2); +connection con1; +SET DEBUG_SYNC="now WAIT_FOR con1_go"; +BEGIN; +INSERT INTO t1(f1) VALUES(1); +SET DEBUG_SYNC="now SIGNAL alter_signal"; +connection default; +--error ER_DUP_ENTRY +reap; +connection con1; +rollback; +connection default; +disconnect con1; +DROP TABLE t1; + +CREATE TABLE t1(f1 CHAR(100), f2 CHAR(100) as (f1) VIRTUAL)ENGINE=InnoDB; +--error ER_DUP_FIELDNAME +ALTER TABLE t1 ADD COLUMN f3 CHAR(100) AS (f2) VIRTUAL, ADD INDEX(f3(10), f1, f3(12)); +DROP TABLE t1; +SET DEBUG_SYNC=RESET; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 6f546dfbd94..d6330cb5906 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -297,7 +297,7 @@ dict_table_try_drop_aborted( && !UT_LIST_GET_FIRST(table->locks)) { /* Silence a debug assertion in row_merge_drop_indexes(). */ ut_d(table->acquire()); - row_merge_drop_indexes(trx, table, TRUE); + row_merge_drop_indexes(trx, table, true); ut_d(table->release()); ut_ad(table->get_ref_count() == ref_count); trx_commit_for_mysql(trx); diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index efefa40e69f..1667e1a0b20 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -911,7 +911,7 @@ dict_mem_fill_vcol_from_v_indexes( Later virtual column set will be refreshed during loading of table. */ if (!dict_index_has_virtual(index) - || index->has_new_v_col) { + || index->has_new_v_col()) { continue; } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index ccc3fe3b921..1f6dbe1eda9 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -248,13 +248,6 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx @return whether the table will be rebuilt */ bool need_rebuild () const { return(old_table != new_table); } - /** Clear uncommmitted added indexes after a failed operation. */ - void clear_added_indexes() - { - for (ulint i= 0; i < num_to_add_index; i++) - add_index[i]->detach_columns(true); - } - /** Share context between partitions. @param[in] ctx context from another partition of the table */ void set_shared_data(const inplace_alter_handler_ctx& ctx) @@ -272,6 +265,45 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx } } + /** @return whether the given column is being added */ + bool is_new_vcol(const dict_v_col_t &v_col) const + { + for (ulint i= 0; i < num_to_add_vcol; i++) + if (&add_vcol[i] == &v_col) + return true; + return false; + } + + /** During rollback, make newly added indexes point to + newly added virtual columns. */ + void clean_new_vcol_index() + { + ut_ad(old_table == new_table); + const dict_index_t *index= dict_table_get_first_index(old_table); + while ((index= dict_table_get_next_index(index)) != NULL) + { + if (!index->has_virtual() || index->is_committed()) + continue; + ulint n_drop_new_vcol= index->get_new_n_vcol(); + for (ulint i= 0; n_drop_new_vcol && i < index->n_fields; i++) + { + dict_col_t *col= index->fields[i].col; + /* Skip the non-virtual and old virtual columns */ + if (!col->is_virtual()) + continue; + dict_v_col_t *vcol= reinterpret_cast(col); + if (!is_new_vcol(*vcol)) + continue; + + dict_v_col_t *drop_vcol= index->new_vcol_info-> + add_drop_v_col(index->heap, vcol, n_drop_new_vcol); + /* Re-assign the index field with newly stored virtual column */ + index->fields[i].col= reinterpret_cast(drop_vcol); + n_drop_new_vcol--; + } + } + } + private: // Disable copying ha_innobase_inplace_ctx(const ha_innobase_inplace_ctx&); @@ -2722,7 +2754,7 @@ online_retry_drop_indexes_low( ut_ad(table->get_ref_count() >= 1); if (table->drop_aborted) { - row_merge_drop_indexes(trx, table, TRUE); + row_merge_drop_indexes(trx, table, true); } } @@ -5146,7 +5178,7 @@ error_handled: online_retry_drop_indexes_with_trx(user_table, ctx->trx); } else { ut_ad(!ctx->need_rebuild()); - row_merge_drop_indexes(ctx->trx, user_table, TRUE); + row_merge_drop_indexes(ctx->trx, user_table, true); trx_commit_for_mysql(ctx->trx); } @@ -6388,7 +6420,6 @@ oom: that we hold at most a shared lock on the table. */ m_prebuilt->trx->error_info = NULL; ctx->trx->error_state = DB_SUCCESS; - ctx->clear_added_indexes(); DBUG_RETURN(true); } @@ -6483,17 +6514,18 @@ temparary index prefix @param table the TABLE @param locked TRUE=table locked, FALSE=may need to do a lazy drop @param trx the transaction -*/ -static MY_ATTRIBUTE((nonnull)) +@param alter_trx transaction which takes S-lock on the table + while creating the index */ +static void innobase_rollback_sec_index( -/*========================*/ - dict_table_t* user_table, - const TABLE* table, - ibool locked, - trx_t* trx) + dict_table_t* user_table, + const TABLE* table, + bool locked, + trx_t* trx, + const trx_t* alter_trx=NULL) { - row_merge_drop_indexes(trx, user_table, locked); + row_merge_drop_indexes(trx, user_table, locked, alter_trx); /* Free the table->fts only if there is no FTS_DOC_ID in the table */ @@ -6587,7 +6619,12 @@ rollback_inplace_alter_table( DBUG_ASSERT(ctx->new_table == prebuilt->table); innobase_rollback_sec_index( - prebuilt->table, table, FALSE, ctx->trx); + prebuilt->table, table, + (ha_alter_info->alter_info->requested_lock + == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE), + ctx->trx, prebuilt->trx); + + ctx->clean_new_vcol_index(); } trx_commit_for_mysql(ctx->trx); diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index a4defe4d92a..7ca1ad9ecd3 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -671,6 +671,35 @@ struct dict_v_col_t{ }; +/** Data structure for newly added virtual column in a index. +It is used only during rollback_inplace_alter_table() of +addition of index depending on newly added virtual columns +and uses index heap. Should be freed when index is being +removed from cache. */ +struct dict_add_v_col_info +{ + ulint n_v_col; + dict_v_col_t *v_col; + + /** Add the newly added virtual column while rollbacking + the index which contains new virtual columns + @param col virtual column to be duplicated + @param offset offset where to duplicate virtual column */ + dict_v_col_t* add_drop_v_col(mem_heap_t *heap, dict_v_col_t *col, + ulint offset) + { + ut_ad(n_v_col); + ut_ad(offset < n_v_col); + if (!v_col) + v_col= static_cast + (mem_heap_alloc(heap, n_v_col * sizeof *v_col)); + new (&v_col[offset]) dict_v_col_t(); + v_col[offset].m_col= col->m_col; + v_col[offset].v_pos= col->v_pos; + return &v_col[offset]; + } +}; + /** Data structure for newly added virtual column in a table */ struct dict_add_v_col_t{ /** number of new virtual column */ @@ -892,9 +921,13 @@ struct dict_index_t{ dict_field_t* fields; /*!< array of field descriptions */ st_mysql_ftparser* parser; /*!< fulltext parser plugin */ - bool has_new_v_col; - /*!< whether it has a newly added virtual - column in ALTER */ + + /** It just indicates whether newly added virtual column + during alter. It stores column in case of alter failure. + It should use heap from dict_index_t. It should be freed + while removing the index from table. */ + dict_add_v_col_info* new_vcol_info; + bool index_fts_syncing;/*!< Whether the fts index is still syncing in the background; FIXME: remove this and use MDL */ @@ -1028,9 +1061,8 @@ struct dict_index_t{ /** @return whether the index is corrupted */ inline bool is_corrupted() const; - /** Detach the virtual columns from the index that is to be removed. - @param whether to reset fields[].col */ - void detach_columns(bool clear= false) + /** Detach the virtual columns from the index that is to be removed. */ + void detach_columns() { if (!has_virtual()) return; @@ -1040,14 +1072,36 @@ struct dict_index_t{ if (!col || !col->is_virtual()) continue; col->detach(*this); - if (clear) - fields[i].col= NULL; } } /** @return whether this is the change buffer */ bool is_ibuf() const { return UNIV_UNLIKELY(type & DICT_IBUF); } + /** Assign the number of new column to be added as a part + of the index + @param n_vcol number of virtual columns to be added */ + void assign_new_v_col(ulint n_vcol) + { + new_vcol_info= static_cast( + mem_heap_zalloc(heap, sizeof *new_vcol_info)); + new_vcol_info->n_v_col= n_vcol; + } + + /* @return whether index has new virtual column */ + bool has_new_v_col() const + { + return new_vcol_info != NULL; + } + + /* @return number of newly added virtual column */ + ulint get_new_n_vcol() const + { + if (new_vcol_info) + return new_vcol_info->n_v_col; + return 0; + } + #ifdef BTR_CUR_HASH_ADAPT /** @return a clone of this */ dict_index_t* clone() const; @@ -1870,6 +1924,17 @@ public: /** mysql_row_templ_t for base columns used for compute the virtual columns */ dict_vcol_templ_t* vc_templ; + + /* @return whether the table has any other transcation lock + other than the given transaction */ + bool has_lock_other_than(const trx_t *trx) const + { + for (lock_t *lock= UT_LIST_GET_FIRST(locks); lock; + lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) + if (lock->trx != trx) + return true; + return false; + } }; inline bool table_name_t::is_temporary() const diff --git a/storage/innobase/include/row0merge.h b/storage/innobase/include/row0merge.h index 0d48fbd2e8a..dfd1d9fb9fd 100644 --- a/storage/innobase/include/row0merge.h +++ b/storage/innobase/include/row0merge.h @@ -167,18 +167,20 @@ row_merge_drop_indexes_dict( table_id_t table_id)/*!< in: table identifier */ MY_ATTRIBUTE((nonnull)); -/*********************************************************************//** -Drop those indexes which were created before an error occurred. +/** Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, -because the transaction will not be committed. */ +because the transaction will not be committed. +@param trx dictionary transaction +@param table table containing the indexes +@param locked True if table is locked, + false - may need to do lazy drop +@param alter_trx Alter table transaction */ void row_merge_drop_indexes( -/*===================*/ - trx_t* trx, /*!< in/out: transaction */ - dict_table_t* table, /*!< in/out: table containing the indexes */ - ibool locked) /*!< in: TRUE=table locked, - FALSE=may need to do a lazy drop */ - MY_ATTRIBUTE((nonnull)); + trx_t* trx, + dict_table_t* table, + bool locked, + const trx_t* alter_trx=NULL); /*********************************************************************//** Drop all partially created indexes during crash recovery. */ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 835d74043fd..e3b3f2c2762 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3696,17 +3696,20 @@ row_merge_drop_indexes_dict( trx->op_info = ""; } -/*********************************************************************//** -Drop indexes that were created before an error occurred. +/** Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, -because the transaction will not be committed. */ +because the transaction will not be committed. +@param trx dictionary transaction +@param table table containing the indexes +@param locked True if table is locked, + false - may need to do lazy drop +@param alter_trx Alter table transaction */ void row_merge_drop_indexes( -/*===================*/ - trx_t* trx, /*!< in/out: dictionary transaction */ - dict_table_t* table, /*!< in/out: table containing the indexes */ - ibool locked) /*!< in: TRUE=table locked, - FALSE=may need to do a lazy drop */ + trx_t* trx, + dict_table_t* table, + bool locked, + const trx_t* alter_trx) { dict_index_t* index; dict_index_t* next_index; @@ -3732,7 +3735,7 @@ row_merge_drop_indexes( A concurrent purge will be prevented by dict_operation_lock. */ if (!locked && (table->get_ref_count() > 1 - || UT_LIST_GET_FIRST(table->locks))) { + || table->has_lock_other_than(alter_trx))) { /* We will have to drop the indexes later, when the table is guaranteed to be no longer in use. Mark the indexes as incomplete and corrupted, so that other @@ -4363,7 +4366,7 @@ row_merge_create_index( dberr_t err; ulint n_fields = index_def->n_fields; ulint i; - bool has_new_v_col = false; + ulint n_add_vcol = 0; DBUG_ENTER("row_merge_create_index"); @@ -4391,7 +4394,7 @@ row_merge_create_index( ut_ad(ifield->col_no >= table->n_v_def); name = add_v->v_col_name[ ifield->col_no - table->n_v_def]; - has_new_v_col = true; + n_add_vcol++; } else { name = dict_table_get_v_col_name( table, ifield->col_no); @@ -4410,7 +4413,9 @@ row_merge_create_index( if (err == DB_SUCCESS) { ut_ad(index != index_template); index->parser = index_def->parser; - index->has_new_v_col = has_new_v_col; + if (n_add_vcol) { + index->assign_new_v_col(n_add_vcol); + } /* Note the id of the transaction that created this index, we use it to restrict readers from accessing this index, to ensure read consistency. */ diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index e79784a5a5f..024625e9e0a 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -729,7 +729,7 @@ row_purge_skip_uncommitted_virtual_index( not support LOCK=NONE when adding an index on newly added virtual column.*/ while (index != NULL && dict_index_has_virtual(index) - && !index->is_committed() && index->has_new_v_col) { + && !index->is_committed() && index->has_new_v_col()) { index = dict_table_get_next_index(index); } } From e95cdc451a969ab8186eabe76be19f578182e946 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 12 Apr 2021 04:11:28 +0200 Subject: [PATCH 11/15] MDEV-21484: galera_sst_mariabackup_encrypt_with_key test failed This commit removes the mtr test galera_sst_mariabackup_encrypt_with_key from the list of disabled tests because the problem with it has already been fixed. --- mysql-test/suite/galera/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 6285da7b11c..d9483864844 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -20,7 +20,6 @@ galera_mdl_race : MDEV-21524: galera.galera_mdl_race MTR failed: query 'reap' su galera_parallel_simple : MDEV-20318 galera.galera_parallel_simple fails galera_partition : MDEV-21806: galera.galera_partition MTR failed: failed to recover from DONOR state galera_shutdown_nonprim : MDEV-21493 galera.galera_shutdown_nonprim -galera_sst_mariabackup_encrypt_with_key : MDEV-21484 galera_sst_mariabackup_encrypt_with_key galera_var_node_address : MDEV-20485 Galera test failure galera_wan : MDEV-17259 Test failure on galera.galera_wan partition : MDEV-19958 Galera test failure on galera.partition From f8bf2a0170b385bbba8f9f8dc97841f58229d39a Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 12 Apr 2021 19:28:10 +0700 Subject: [PATCH 12/15] MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning in case it is executed in PS (prepared statement) mode The EXPLAIN EXTENDED statement run as a prepared statement can produce extra warning comparing with a case when EXPLAIN EXTENDED statement is run as a regular statement. For example, the following test case CREATE TABLE t1 (c int); CREATE TABLE t2 (d int); EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1; produces the extra warning "Field or reference 'c' of SELECT #2 was resolved in SELECT #1" in case the above mentioned "EXPLAIN EXTENDED" statement is executed in PS mode, that is by submitting the following statements: PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1"; EXECUTE stmt; The reason of the extra warning emittion is in a way items are handled (being fixed) during execution of the JOIN::prepare() method. The method Item_field::fix_fields() calls the find_field_in_tables() function in case a field hasn't been associated yet with the item. Implementation of the find_field_in_tables() function first checks whether a table containing the required field was already opened and cached. It is done by checking the data member item->cached_table. This data member is set on handling the PRERARE FROM statement and checked on executing the EXECUTE statement. If the data member item->cached_table is set the find_field_in_tables() function invoked and the mark_select_range_as_dependent() function called if the field is an outer referencee. The mark_select_range_as_dependent() function calls the mark_as_dependent() function that finally invokes the push_warning_printf() function that produces extra warning. To fix the issue, calling of push_warning_printf() is elimited in case it was run indirectly in result of hanlding already opened table from the Item_field::fix_fields() method. --- mysql-test/r/ps.result | 37 +++++++++++++++++++++++++++++++++++++ mysql-test/t/ps.test | 20 ++++++++++++++++++++ sql/item.cc | 30 ++++++++++++++++++------------ sql/item.h | 3 ++- sql/item_subselect.h | 3 ++- sql/sql_base.cc | 2 +- 6 files changed, 80 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 17284a3cad8..4ee72f10785 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -5419,5 +5419,42 @@ id select_type table type possible_keys key key_len ref rows Extra DEALLOCATE PREPARE stmt; DROP TABLE t1; # +# MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning +# in case it is executed in PS (prepared statement) mode +# +CREATE TABLE t1 (c int); +CREATE TABLE t2 (d int); +# EXPLAIN EXTENDED in regular way (not PS mode) +EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select 1 from `test`.`t2` where 0) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1` +SHOW WARNINGS; +Level Code Message +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select 1 from `test`.`t2` where 0) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1` +# Now run the same EXPLAIN EXTENDED in PS mode. Number of warnings +# and their content must be the same as in case running the statement +# in regular way +PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1"; +Warnings: +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select 1 from `test`.`t2` where 0) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1` +SHOW WARNINGS; +Level Code Message +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select 1 from `test`.`t2` where 0) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1` +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +# # End of 10.2 tests # diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index a267c8b0e42..5b86f82a9cb 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -4926,6 +4926,26 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo # +--echo # MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning +--echo # in case it is executed in PS (prepared statement) mode +--echo # +CREATE TABLE t1 (c int); +CREATE TABLE t2 (d int); + +--echo # EXPLAIN EXTENDED in regular way (not PS mode) +EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1; +SHOW WARNINGS; + +--echo # Now run the same EXPLAIN EXTENDED in PS mode. Number of warnings +--echo # and their content must be the same as in case running the statement +--echo # in regular way +PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1"; +EXECUTE stmt; +SHOW WARNINGS; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index 45f40874ddb..55d135c660e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4668,11 +4668,14 @@ bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) @param resolved_item item which was resolved in outer SELECT(for warning) @param mark_item item which should be marked (can be differ in case of substitution) + @param suppress_warning_output flag specifying whether to suppress output of + a warning message */ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, Item_ident *resolved_item, - Item_ident *mark_item) + Item_ident *mark_item, + bool suppress_warning_output) { DBUG_ENTER("mark_as_dependent"); @@ -4685,7 +4688,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, if (current->mark_as_dependent(thd, last, /** resolved_item psergey-thu **/ mark_item)) DBUG_RETURN(TRUE); - if (thd->lex->describe & DESCRIBE_EXTENDED) + if ((thd->lex->describe & DESCRIBE_EXTENDED) && !suppress_warning_output) { const char *db_name= (resolved_item->db_name ? resolved_item->db_name : ""); @@ -4714,6 +4717,8 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, @param found_item Item which was found during resolving (if resolved identifier belongs to VIEW) @param resolved_item Identifier which was resolved + @param suppress_warning_output flag specifying whether to suppress output of + a warning message @note We have to mark all items between current_sel (including) and @@ -4727,7 +4732,8 @@ void mark_select_range_as_dependent(THD *thd, SELECT_LEX *last_select, SELECT_LEX *current_sel, Field *found_field, Item *found_item, - Item_ident *resolved_item) + Item_ident *resolved_item, + bool suppress_warning_output) { /* Go from current SELECT to SELECT where field was resolved (it @@ -4762,7 +4768,7 @@ void mark_select_range_as_dependent(THD *thd, found_field->table->map; prev_subselect_item->const_item_cache= 0; mark_as_dependent(thd, last_select, current_sel, resolved_item, - dependent); + dependent, suppress_warning_output); } } @@ -5228,7 +5234,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) context->select_lex, this, ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ? - (Item_ident*) (*reference) : 0)); + (Item_ident*) (*reference) : 0), false); return 0; } } @@ -5240,7 +5246,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) context->select_lex, this, ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ? (Item_ident*) (*reference) : - 0)); + 0), false); if (thd->lex->in_sum_func && thd->lex->in_sum_func->nest_level >= select->nest_level) { @@ -5354,7 +5360,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) set_max_sum_func_level(thd, select); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, rf, - rf); + rf, false); return 0; } @@ -5367,7 +5373,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) set_max_sum_func_level(thd, select); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, - this, (Item_ident*)*reference); + this, (Item_ident*)*reference, false); if (last_checked_context->select_lex->having_fix_field) { Item_ref *rf; @@ -7401,7 +7407,7 @@ public: if (tbl->table == item->field->table) { if (sel != current_select) - mark_as_dependent(thd, sel, current_select, item, item); + mark_as_dependent(thd, sel, current_select, item, item, false); return; } } @@ -7596,7 +7602,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) ((refer_type == REF_ITEM || refer_type == FIELD_ITEM) ? (Item_ident*) (*reference) : - 0)); + 0), false); /* view reference found, we substituted it instead of this Item, so can quit @@ -7646,7 +7652,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) goto error; thd->change_item_tree(reference, fld); mark_as_dependent(thd, last_checked_context->select_lex, - current_sel, fld, fld); + current_sel, fld, fld, false); /* A reference is resolved to a nest level that's outer or the same as the nest level of the enclosing set function : adjust the value of @@ -7669,7 +7675,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) /* Should be checked in resolve_ref_in_select_and_group(). */ DBUG_ASSERT(*ref && (*ref)->fixed); mark_as_dependent(thd, last_checked_context->select_lex, - context->select_lex, this, this); + context->select_lex, this, this, false); /* A reference is resolved to a nest level that's outer or the same as the nest level of the enclosing set function : adjust the value of diff --git a/sql/item.h b/sql/item.h index cb1e8519b27..b13336939f9 100644 --- a/sql/item.h +++ b/sql/item.h @@ -6088,7 +6088,8 @@ void mark_select_range_as_dependent(THD *thd, st_select_lex *last_select, st_select_lex *current_sel, Field *found_field, Item *found_item, - Item_ident *resolved_item); + Item_ident *resolved_item, + bool suppress_warning_output); extern Cached_item *new_Cached_item(THD *thd, Item *item, bool pass_through_ref); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 130f90839e3..7b2078939f1 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -283,7 +283,8 @@ public: friend bool Item_ref::fix_fields(THD *, Item **); friend void mark_select_range_as_dependent(THD*, st_select_lex*, st_select_lex*, - Field*, Item*, Item_ident*); + Field*, Item*, Item_ident*, + bool); friend bool convert_join_subqueries_to_semijoins(JOIN *join); }; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b8d18abb50c..f10846acdd7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6046,7 +6046,7 @@ find_field_in_tables(THD *thd, Item_ident *item, if (!all_merged && current_sel != last_select) { mark_select_range_as_dependent(thd, last_select, current_sel, - found, *ref, item); + found, *ref, item, true); } } return found; From 68e0defc5be41e42f5f9d050a436a5f88277a586 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 12 Apr 2021 15:46:23 +0200 Subject: [PATCH 13/15] MDEV-25182 Complex query in Store procedure corrupts results At the second execution of the PS 1. mark_as_dependent() is called with the same parameters as at the first execution (select#4 and select#3) 2. as outer_select (select#3) has been already merged at the first execution of PS it cannot be reached using the outer_select() function anymore (and so can not stop iteration). 3. as a result all selects towards the top level select including the select for 'ca' are marked as uncacheable. 4. Marked uncacheable it executed incorrectly triggering filling its temporary table several times and using freed memory at the end. To avoid the problem we use name resolution context to go "up". NOTE: problem also exists in 10.2 but has no visible effect on execution. That is why the problem is fixed in 10.2. The patch also add debug logging of important procedures and better specify parameters types of st_select_lex::mark_as_dependent. --- mysql-test/r/derived_opt.result | 27 +++++++++++++++++++++++++++ mysql-test/t/derived_opt.test | 33 +++++++++++++++++++++++++++++++++ sql/item.cc | 3 +++ sql/sql_lex.cc | 10 +++++++--- sql/sql_lex.h | 3 ++- sql/sql_select.cc | 8 +++++--- 6 files changed, 77 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/derived_opt.result b/mysql-test/r/derived_opt.result index 0e8b49d5714..069b0aa65c9 100644 --- a/mysql-test/r/derived_opt.result +++ b/mysql-test/r/derived_opt.result @@ -537,4 +537,31 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort set join_cache_level=default; DROP TABLE t1,t2; +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch="derived_merge=on"; +CREATE TABLE t1 (id int, d2 datetime, id1 int) ; +insert into t1 values (1,'2020-01-01 10:10:10',1),(2,'2020-01-01 10:10:10',2),(3,'2020-01-01 10:10:10',3); +CREATE TABLE t2 (id int, d1 datetime, id1 int) ; +insert into t2 values (1,'2020-01-01 10:10:10',1),(2,'2020-01-01 10:10:10',2),(3,'2020-01-01 10:10:10',2); +prepare stmt from " +SELECT * from + (SELECT min(d2) AS d2, min(d1) AS d1 FROM + (SELECT t1.d2 AS d2, (SELECT t2.d1 + FROM t2 WHERE t1.id1 = t2.id1 + ORDER BY t2.id DESC LIMIT 1) AS d1 + FROM t1 + ) dt2 + ) ca + ORDER BY ca.d2;"; +execute stmt; +d2 d1 +2020-01-01 10:10:10 2020-01-01 10:10:10 +execute stmt; +d2 d1 +2020-01-01 10:10:10 2020-01-01 10:10:10 +set optimizer_switch= @save_optimizer_switch; +DROP TABLE t1, t2; +# +# End of 10.3 tests +# set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/t/derived_opt.test b/mysql-test/t/derived_opt.test index aab95f69f26..305cac120a0 100644 --- a/mysql-test/t/derived_opt.test +++ b/mysql-test/t/derived_opt.test @@ -401,5 +401,38 @@ set join_cache_level=default; DROP TABLE t1,t2; +# +# MDEV-25182: Complex query in Store procedure corrupts results +# +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch="derived_merge=on"; + +CREATE TABLE t1 (id int, d2 datetime, id1 int) ; +insert into t1 values (1,'2020-01-01 10:10:10',1),(2,'2020-01-01 10:10:10',2),(3,'2020-01-01 10:10:10',3); + +CREATE TABLE t2 (id int, d1 datetime, id1 int) ; +insert into t2 values (1,'2020-01-01 10:10:10',1),(2,'2020-01-01 10:10:10',2),(3,'2020-01-01 10:10:10',2); + +prepare stmt from " +SELECT * from + (SELECT min(d2) AS d2, min(d1) AS d1 FROM + (SELECT t1.d2 AS d2, (SELECT t2.d1 + FROM t2 WHERE t1.id1 = t2.id1 + ORDER BY t2.id DESC LIMIT 1) AS d1 + FROM t1 + ) dt2 + ) ca + ORDER BY ca.d2;"; + +execute stmt; +execute stmt; + +set optimizer_switch= @save_optimizer_switch; +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.3 tests +--echo # + # The following command must be the last one the file set optimizer_switch=@exit_optimizer_switch; diff --git a/sql/item.cc b/sql/item.cc index 55d135c660e..42272fe0148 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4678,6 +4678,9 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, bool suppress_warning_output) { DBUG_ENTER("mark_as_dependent"); + DBUG_PRINT("info", ("current select: %d (%p) last: %d (%p)", + current->select_number, current, + (last ? last->select_number : 0), last)); /* store pointer on SELECT_LEX from which item is dependent */ if (mark_item && mark_item->can_be_depended) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5059e4f656e..bfe773b2c00 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2470,7 +2470,7 @@ void st_select_lex_unit::exclude_tree() */ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, - Item *dependency) + Item_ident *dependency) { DBUG_ASSERT(this != last); @@ -2478,10 +2478,14 @@ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, /* Mark all selects from resolved to 1 before select where was found table as depended (of select where was found table) + + We move by name resolution context, bacause during merge can some select + be excleded from SELECT tree */ - SELECT_LEX *s= this; + Name_resolution_context *c= &this->context; do { + SELECT_LEX *s= c->select_lex; if (!(s->uncacheable & UNCACHEABLE_DEPENDENT_GENERATED)) { // Select is dependent of outer select @@ -2503,7 +2507,7 @@ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, if (subquery_expr && subquery_expr->mark_as_dependent(thd, last, dependency)) return TRUE; - } while ((s= s->outer_select()) != last && s != 0); + } while ((c= c->outer_context) != NULL && (c->select_lex != last)); is_correlated= TRUE; this->master_unit()->item->is_correlated= TRUE; return FALSE; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f733f783d0e..31751a16471 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1004,7 +1004,8 @@ public: } inline bool is_subquery_function() { return master_unit()->item != 0; } - bool mark_as_dependent(THD *thd, st_select_lex *last, Item *dependency); + bool mark_as_dependent(THD *thd, st_select_lex *last, + Item_ident *dependency); void set_braces(bool value) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7bfbf719017..90c071803a1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12097,10 +12097,12 @@ ha_rows JOIN_TAB::get_examined_rows() bool JOIN_TAB::preread_init() { TABLE_LIST *derived= table->pos_in_table_list; + DBUG_ENTER("JOIN_TAB::preread_init"); + if (!derived || !derived->is_materialized_derived()) { preread_init_done= TRUE; - return FALSE; + DBUG_RETURN(FALSE); } /* Materialize derived table/view. */ @@ -12108,7 +12110,7 @@ bool JOIN_TAB::preread_init() derived->is_recursive_with_table()) && mysql_handle_single_derived(join->thd->lex, derived, DT_CREATE | DT_FILL)) - return TRUE; + DBUG_RETURN(TRUE); preread_init_done= TRUE; if (select && select->quick) @@ -12125,7 +12127,7 @@ bool JOIN_TAB::preread_init() if (table->fulltext_searched) init_ftfuncs(join->thd, join->select_lex, MY_TEST(join->order)); - return FALSE; + DBUG_RETURN(FALSE); } From f776fa96b4e04644155087a2c3919be13c1000a6 Mon Sep 17 00:00:00 2001 From: Dmitriy Karpovskiy Date: Wed, 3 Feb 2021 12:04:06 +0300 Subject: [PATCH 14/15] MDEV-24135: Print warnings in XML, save test retries in XML, save the combinations in XML, replace the special symbols in the XML comment --- mysql-test/lib/mtr_report.pm | 30 +++++++++++++++++++----------- mysql-test/mysql-test-run.pl | 10 +++++++--- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 98ed77eea0f..8142b0a5cbb 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -497,23 +497,21 @@ sub mtr_report_stats ($$$$) { $test_time = sprintf("%.3f", $test->{timer} / 1000); $test->{'name'} =~ s/$current_suite\.//; - my $test_result; - - # if a test case has to be retried it should have the result MTR_RES_FAILED in jUnit XML - if ($test->{'retries'} > 0) { - $test_result = "MTR_RES_FAILED"; + my $combinations; + if (defined($test->{combinations})){ + $combinations = join ',', sort @{$test->{combinations}}; } else { - $test_result = $test->{'result'}; + $combinations = ""; } - $xml_report .= qq(\t\t{'comment'}; - $comment =~ s/[\"]//g; + my $comment= replace_special_symbols($test->{'comment'}); - # if a test case has to be retried it should have the result MTR_RES_FAILED in jUnit XML - if ($test->{'result'} eq "MTR_RES_FAILED" || $test->{'retries'} > 0) { + if ($test->{'result'} eq "MTR_RES_FAILED") { my $logcontents = $test->{'logfile-failed'} || $test->{'logfile'}; + $logcontents= $logcontents.$test->{'warnings'}."\n"; # remove any double ] that would end the cdata $logcontents =~ s/]]/\x{fffd}/g; # replace wide characters that aren't allowed in XML 1.0 @@ -576,6 +574,16 @@ sub mtr_print_line () { print '-' x 74 . "\n"; } +sub replace_special_symbols($) { + my $text= shift; + $text =~ s/&/&/g; + $text =~ s/'/'/g; + $text =~ s/"/"/g; + $text =~ s//>/g; + return $text; +} + sub mtr_print_thick_line { my $char= shift || '='; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fd25c28dc06..5e46cfe8eff 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -888,9 +888,13 @@ sub run_test_server ($$$) { rename $log_file_name, $log_file_name.".failed"; } - delete($result->{result}); - $result->{retries}= $retries+1; - $result->write_test($sock, 'TESTCASE'); + { + local @$result{'retries', 'result'}; + delete $result->{result}; + $result->{retries}= $retries+1; + $result->write_test($sock, 'TESTCASE'); + } + push(@$completed, $result); next; } } From e262eb165c197083df9f4986ab54c5b2dcbd6290 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 13 Apr 2021 10:09:16 +0530 Subject: [PATCH 15/15] MDEV-24971 InnoDB access freed virtual column after rollback of secondary index - Fixing post-fix failure. In clean_new_vcol_index(), InnoDB has the wrong offset to store the virtual column --- storage/innobase/handler/handler0alter.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 1f6dbe1eda9..3ac4f4fe4c1 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -296,10 +296,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx continue; dict_v_col_t *drop_vcol= index->new_vcol_info-> - add_drop_v_col(index->heap, vcol, n_drop_new_vcol); + add_drop_v_col(index->heap, vcol, --n_drop_new_vcol); /* Re-assign the index field with newly stored virtual column */ index->fields[i].col= reinterpret_cast(drop_vcol); - n_drop_new_vcol--; } } }