From b1d74b7e7214178ab0e81b5fb4c27165ecd9f83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 29 Apr 2024 10:13:03 +0300 Subject: [PATCH] MDEV-33997 : Assertion `((WSREP_PROVIDER_EXISTS_ && this->variables.wsrep_on) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()' failed in int THD::binlog_write_row(TABLE*, bool, const uchar*) Problem was that we did not found that table was partitioned and then we should find what is actual underlaying storage engine. We should not use RSU for !InnoDB tables. Signed-off-by: Julius Goryavsky --- mysql-test/suite/wsrep/r/MDEV-33997.result | 38 ++++++++++++++ mysql-test/suite/wsrep/t/MDEV-33997.cnf | 9 ++++ .../suite/wsrep/t/MDEV-33997.combinations | 4 ++ mysql-test/suite/wsrep/t/MDEV-33997.test | 49 +++++++++++++++++++ sql/log_event_server.cc | 14 +++--- sql/sql_parse.cc | 7 +++ 6 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/wsrep/r/MDEV-33997.result create mode 100644 mysql-test/suite/wsrep/t/MDEV-33997.cnf create mode 100644 mysql-test/suite/wsrep/t/MDEV-33997.combinations create mode 100644 mysql-test/suite/wsrep/t/MDEV-33997.test diff --git a/mysql-test/suite/wsrep/r/MDEV-33997.result b/mysql-test/suite/wsrep/r/MDEV-33997.result new file mode 100644 index 00000000000..f0e43462054 --- /dev/null +++ b/mysql-test/suite/wsrep/r/MDEV-33997.result @@ -0,0 +1,38 @@ +SET SESSION wsrep_osu_method=RSU; +SET autocommit=0; +CREATE TABLE t (c INT) ENGINE=INNODB PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t VALUES (1); +INSERT INTO t SELECT 1 ; +COMMIT; +SELECT * FROM t; +c +1 +1 +DROP TABLE t; +SET autocommit=1; +SET SESSION wsrep_osu_method=RSU; +CREATE TABLE t (c INT) ENGINE=INNODB PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t SELECT 1 ; +SELECT * FROM t; +c +1 +DROP TABLE t; +SET autocommit=1; +SET SESSION wsrep_osu_method=RSU; +CREATE TABLE t (c INT) ENGINE=MYISAM PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t SELECT 1 ; +ERROR 42000: This version of MariaDB doesn't yet support 'RSU on this table engine' +SELECT * FROM t; +c +DROP TABLE t; +SET SESSION wsrep_osu_method=RSU; +SET autocommit=0; +CREATE TABLE t (c INT) ENGINE=MYISAM PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t VALUES (1); +INSERT INTO t SELECT 1 ; +ERROR 42000: This version of MariaDB doesn't yet support 'RSU on this table engine' +COMMIT; +SELECT * FROM t; +c +1 +DROP TABLE t; diff --git a/mysql-test/suite/wsrep/t/MDEV-33997.cnf b/mysql-test/suite/wsrep/t/MDEV-33997.cnf new file mode 100644 index 00000000000..489c4385dbd --- /dev/null +++ b/mysql-test/suite/wsrep/t/MDEV-33997.cnf @@ -0,0 +1,9 @@ +!include ../my.cnf + +[mysqld.1] +wsrep-on=ON +binlog-format=ROW +innodb-flush-log-at-trx-commit=1 +wsrep-cluster-address=gcomm:// +wsrep-provider=@ENV.WSREP_PROVIDER +innodb-autoinc-lock-mode=2 diff --git a/mysql-test/suite/wsrep/t/MDEV-33997.combinations b/mysql-test/suite/wsrep/t/MDEV-33997.combinations new file mode 100644 index 00000000000..1ce3b45aa1a --- /dev/null +++ b/mysql-test/suite/wsrep/t/MDEV-33997.combinations @@ -0,0 +1,4 @@ +[binlogon] +log-bin + +[binlogoff] diff --git a/mysql-test/suite/wsrep/t/MDEV-33997.test b/mysql-test/suite/wsrep/t/MDEV-33997.test new file mode 100644 index 00000000000..3d015244d7d --- /dev/null +++ b/mysql-test/suite/wsrep/t/MDEV-33997.test @@ -0,0 +1,49 @@ +--source include/have_wsrep.inc +--source include/have_innodb.inc +--source include/have_wsrep_provider.inc +--source include/have_partition.inc +# +# MDEV-33997: Assertion `((WSREP_PROVIDER_EXISTS_ && this->variables.wsrep_on) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()' failed in int THD::binlog_write_row(TABLE*, bool, const uchar*) +# +SET SESSION wsrep_osu_method=RSU; +SET autocommit=0; + +CREATE TABLE t (c INT) ENGINE=INNODB PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t VALUES (1); +INSERT INTO t SELECT 1 ; +COMMIT; +SELECT * FROM t; +DROP TABLE t; + +# +# MDEV-27296 : Assertion `((thd && (WSREP_PROVIDER_EXISTS_ && thd->variables.wsrep_on)) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()' failed +# Second test case +# +SET autocommit=1; +SET SESSION wsrep_osu_method=RSU; +CREATE TABLE t (c INT) ENGINE=INNODB PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t SELECT 1 ; +SELECT * FROM t; +DROP TABLE t; + +# +# We should not allow RSU for MyISAM +# +SET autocommit=1; +SET SESSION wsrep_osu_method=RSU; +CREATE TABLE t (c INT) ENGINE=MYISAM PARTITION BY KEY(c) PARTITIONS 2; +--error ER_NOT_SUPPORTED_YET +INSERT INTO t SELECT 1 ; +SELECT * FROM t; +DROP TABLE t; + +SET SESSION wsrep_osu_method=RSU; +SET autocommit=0; + +CREATE TABLE t (c INT) ENGINE=MYISAM PARTITION BY KEY(c) PARTITIONS 2; +INSERT INTO t VALUES (1); +--error ER_NOT_SUPPORTED_YET +INSERT INTO t SELECT 1 ; +COMMIT; +SELECT * FROM t; +DROP TABLE t; diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index d8056fd4378..69a27ed6350 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -5519,13 +5519,15 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) #ifdef WITH_WSREP if (WSREP(thd)) { - WSREP_WARN("BF applier failed to open_and_lock_tables: %u, fatal: %d " + WSREP_WARN("BF applier thread=%lu failed to open_and_lock_tables for " + "%s, fatal: %d " "wsrep = (exec_mode: %d conflict_state: %d seqno: %lld)", - thd->get_stmt_da()->sql_errno(), - thd->is_fatal_error, - thd->wsrep_cs().mode(), - thd->wsrep_trx().state(), - (long long) wsrep_thd_trx_seqno(thd)); + thd_get_thread_id(thd), + thd->get_stmt_da()->message(), + thd->is_fatal_error, + thd->wsrep_cs().mode(), + thd->wsrep_trx().state(), + wsrep_thd_trx_seqno(thd)); } #endif /* WITH_WSREP */ if (thd->is_error() && diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2d6c7621f7b..01fa466780e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4759,6 +4759,13 @@ mysql_execute_command(THD *thd) thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK; } + /* Only TOI allowed to !InnoDB tables */ + if (!is_innodb && wsrep_OSU_method_get(thd) != WSREP_OSU_TOI) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RSU on this table engine"); + break; + } + // For !InnoDB we start TOI if it is not yet started and hope for the best if (!is_innodb && !wsrep_toi) {