From 5bc12ca9c294002c09b32238e8bdf4de3dc138dc Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 23 Apr 2021 13:04:36 +0400 Subject: [PATCH 01/10] MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions. The name of the table sent as an argument to the handler::init() has the database name in front of it. So we should use table_share->table_name.length. --- storage/spider/mysql-test/spider/r/basic_sql.result | 4 ++++ storage/spider/mysql-test/spider/t/basic_sql.test | 6 ++++++ storage/spider/spd_table.cc | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/storage/spider/mysql-test/spider/r/basic_sql.result b/storage/spider/mysql-test/spider/r/basic_sql.result index 94a09fc317b..ba904b5f577 100644 --- a/storage/spider/mysql-test/spider/r/basic_sql.result +++ b/storage/spider/mysql-test/spider/r/basic_sql.result @@ -717,6 +717,10 @@ TRUNCATE TABLE ta_l; connection master_1; SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') +connection master_1; +create table t2345678911234567892123456789312345678941234567895123234234(id int) ENGINE=SPIDER +COMMENT='host "192.168.21.1", user "spider", password "password", database "test32738123123123"'; +drop table t2345678911234567892123456789312345678941234567895123234234; deinit connection master_1; diff --git a/storage/spider/mysql-test/spider/t/basic_sql.test b/storage/spider/mysql-test/spider/t/basic_sql.test index 5bb040047fc..a3184a14beb 100644 --- a/storage/spider/mysql-test/spider/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/t/basic_sql.test @@ -2677,6 +2677,11 @@ if ($USE_CHILD_GROUP2) --connection master_1 SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a; +--connection master_1 +create table t2345678911234567892123456789312345678941234567895123234234(id int) ENGINE=SPIDER + COMMENT='host "192.168.21.1", user "spider", password "password", database "test32738123123123"'; +drop table t2345678911234567892123456789312345678941234567895123234234; + --echo --echo deinit --disable_warnings @@ -2689,6 +2694,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 DROP DATABASE IF EXISTS auto_test_remote2; } + --disable_query_log --disable_result_log --source test_deinit.inc diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index fd0ece10c1b..495e1483ee6 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -3552,7 +3552,8 @@ int spider_set_connect_info_default( if (!share->tgt_table_names[roop_count] && table_share) { DBUG_PRINT("info",("spider create default tgt_table_names")); - share->tgt_table_names_lengths[roop_count] = share->table_name_length; + share->tgt_table_names_lengths[roop_count] = + table_share->table_name.length; if ( !(share->tgt_table_names[roop_count] = spider_create_table_name_string( table_share->table_name.str, From 4cd92143eae9b397589e5b449d1a85c43b3e4f6b Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 28 Apr 2021 03:56:24 +0530 Subject: [PATCH 02/10] MDEV-25630 Rollback of instant operation adds wrong column to secondary index Problem: ======= InnoDB alter fails before applying instant operation. So rollback assigns wrong column to the secondary index field. It leads to the assert failure in the consecutive alter. Fix: === InnoDB shouldn't do rollback of instant operation when it fails before applying instant operation. --- .../suite/innodb/r/instant_alter.result | 27 +++++++++++++++++++ mysql-test/suite/innodb/t/instant_alter.test | 20 ++++++++++++++ storage/innobase/handler/handler0alter.cc | 7 +++++ 3 files changed, 54 insertions(+) diff --git a/mysql-test/suite/innodb/r/instant_alter.result b/mysql-test/suite/innodb/r/instant_alter.result index b803d968836..110939b5fdb 100644 --- a/mysql-test/suite/innodb/r/instant_alter.result +++ b/mysql-test/suite/innodb/r/instant_alter.result @@ -2854,3 +2854,30 @@ SELECT COUNT(*) FROM t1; COUNT(*) 16 DROP TABLE t1; +# +# MDEV-25630 Rollback of instant operation adds wrong +# column to secondary index +# +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, f4 INT, +PRIMARY KEY(f1, f4), +KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2 (f1 INT, f2 INT, PRIMARY KEY(f1), +FOREIGN KEY fk (f2) REFERENCES t2(f1) +)ENGINE=InnoDB; +ALTER TABLE t1 ADD f5 INT; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t1 DROP COLUMN f3, ADD FOREIGN KEY fk (f1) +REFERENCES x(x); +ERROR HY000: Failed to add the foreign key constraint 'test/fk' to system tables +ALTER TABLE t1 DROP COLUMN f5; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + `f3` int(11) DEFAULT NULL, + `f4` int(11) NOT NULL, + PRIMARY KEY (`f1`,`f4`), + KEY `f2` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; diff --git a/mysql-test/suite/innodb/t/instant_alter.test b/mysql-test/suite/innodb/t/instant_alter.test index 3d567cb0704..3872f080d6b 100644 --- a/mysql-test/suite/innodb/t/instant_alter.test +++ b/mysql-test/suite/innodb/t/instant_alter.test @@ -917,3 +917,23 @@ INSERT INTO t1(a, b) SELECT '', '' FROM seq_1_to_16; SELECT COUNT(*) FROM t1; # Cleanup DROP TABLE t1; + +--echo # +--echo # MDEV-25630 Rollback of instant operation adds wrong +--echo # column to secondary index +--echo # +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, f4 INT, + PRIMARY KEY(f1, f4), + KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2 (f1 INT, f2 INT, PRIMARY KEY(f1), + FOREIGN KEY fk (f2) REFERENCES t2(f1) + )ENGINE=InnoDB; + +ALTER TABLE t1 ADD f5 INT; +SET FOREIGN_KEY_CHECKS=0; +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE t1 DROP COLUMN f3, ADD FOREIGN KEY fk (f1) + REFERENCES x(x); +ALTER TABLE t1 DROP COLUMN f5; +SHOW CREATE TABLE t1; +DROP TABLE t1, t2; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index f523f9a361b..a330cbc5460 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -766,6 +766,13 @@ inline void dict_table_t::rollback_instant( const ulint* col_map) { ut_d(dict_sys.assert_locked()); + + if (cols == old_cols) { + /* Alter fails before instant operation happens. + So there is no need to do rollback instant operation */ + return; + } + dict_index_t* index = indexes.start; mtr_t mtr; mtr.start(); From 206d630ea0c1f89f6c3bd2b8d3d62eafa37a2bc2 Mon Sep 17 00:00:00 2001 From: mkaruza Date: Mon, 26 Apr 2021 11:17:30 +0200 Subject: [PATCH 03/10] MDEV-22227 Assertion `state_ == s_exec' failed in wsrep::client_state::start_transaction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed redundant code for BF abort transaction in `thr_lock.cc`. TOI operations will ignore provided lock_wait_timeout and use `LONG_TIMEOUT` until operation is finished. Reviewed-by: Jan Lindström --- mysql-test/suite/galera/r/MDEV-22227.result | 16 +++ mysql-test/suite/galera/t/MDEV-22227.test | 26 ++++ mysys/thr_lock.c | 127 -------------------- sql/sql_class.h | 1 + sql/wsrep_mysqld.cc | 13 +- 5 files changed, 53 insertions(+), 130 deletions(-) create mode 100644 mysql-test/suite/galera/r/MDEV-22227.result create mode 100644 mysql-test/suite/galera/t/MDEV-22227.test diff --git a/mysql-test/suite/galera/r/MDEV-22227.result b/mysql-test/suite/galera/r/MDEV-22227.result new file mode 100644 index 00000000000..d5afc974555 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-22227.result @@ -0,0 +1,16 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +LOCK TABLE t1 WRITE CONCURRENT; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; +SET lock_wait_timeout= 1; +CREATE VIEW v1 AS SELECT * FROM t1; +connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1b; +SET SESSION wsrep_sync_wait = 0; +connection node_1; +UNLOCK TABLES; +connection node_1a; +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MDEV-22227.test b/mysql-test/suite/galera/t/MDEV-22227.test new file mode 100644 index 00000000000..0ee75b979e2 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-22227.test @@ -0,0 +1,26 @@ +--source include/galera_cluster.inc +--source include/have_log_bin.inc + +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +LOCK TABLE t1 WRITE CONCURRENT; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +# TOI operations will ignore lock_wait_timeout +SET lock_wait_timeout= 1; +--send CREATE VIEW v1 AS SELECT * FROM t1 + +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1b +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Waiting for table level lock' +--source include/wait_condition.inc + +--connection node_1 +UNLOCK TABLES; + +--connection node_1a +--reap + +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index c798c8595e7..363e1a1ea26 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -95,24 +95,6 @@ my_bool thr_lock_inited=0; ulong locks_immediate = 0L, locks_waited = 0L; enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE; -#ifdef WITH_WSREP -static wsrep_thd_is_brute_force_fun wsrep_thd_is_brute_force= NULL; -static wsrep_abort_thd_fun wsrep_abort_thd= NULL; -static my_bool wsrep_debug; -static my_bool wsrep_convert_LOCK_to_trx; -static wsrep_on_fun wsrep_on = NULL; - -void wsrep_thr_lock_init( - wsrep_thd_is_brute_force_fun bf_fun, wsrep_abort_thd_fun abort_fun, - my_bool debug, my_bool convert_LOCK_to_trx, wsrep_on_fun on_fun -) { - wsrep_thd_is_brute_force = bf_fun; - wsrep_abort_thd = abort_fun; - wsrep_debug = debug; - wsrep_convert_LOCK_to_trx= convert_LOCK_to_trx; - wsrep_on = on_fun; -} -#endif /* The following constants are only for debug output */ #define MAX_THREADS 1000 #define MAX_LOCKS 1000 @@ -652,93 +634,6 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, DBUG_RETURN(result); } -#ifdef WITH_WSREP -/* - * If brute force applier would need to wait for a thr lock, - * it needs to make sure that it will get the lock without (too much) - * delay. - * We identify here the owners of blocking locks and ask them to - * abort. We then put our lock request in the first place in the - * wait queue. When lock holders abort (one by one) the lock release - * algorithm should grant the lock to us. We rely on this and proceed - * to wait_for_locks(). - * wsrep_break_locks() should be called in all the cases, where lock - * wait would happen. - * - * TODO: current implementation might not cover all possible lock wait - * situations. This needs an review still. - * TODO: lock release, might favor some other lock (instead our bf). - * This needs an condition to check for bf locks first. - * TODO: we still have a debug fprintf, this should be removed - */ -static my_bool -wsrep_break_lock( - THR_LOCK_DATA *data, struct st_lock_list *lock_queue1, - struct st_lock_list *wait_queue) -{ - if (wsrep_on && wsrep_on(data->owner->mysql_thd) && - wsrep_thd_is_brute_force && - wsrep_thd_is_brute_force(data->owner->mysql_thd, TRUE)) - { - THR_LOCK_DATA *holder; - - /* if locking session conversion to transaction has been enabled, - we know that this conflicting lock must be read lock and furthermore, - lock holder is read-only. It is safe to wait for him. - */ -#ifdef TODO_WHEN_LOCK_TABLES_IS_A_TRANSACTION - if (wsrep_convert_LOCK_to_trx && - (THD*)(data->owner->mysql_thd)->in_lock_tables) - { - if (wsrep_debug) - fprintf(stderr,"WSREP wsrep_break_lock read lock untouched\n"); - return FALSE; - } -#endif - if (wsrep_debug) - fprintf(stderr,"WSREP wsrep_break_lock aborting locks\n"); - - /* aborting lock holder(s) here */ - for (holder=(lock_queue1) ? lock_queue1->data : NULL; - holder; - holder=holder->next) - { - if (!wsrep_thd_is_brute_force(holder->owner->mysql_thd, TRUE)) - { - wsrep_abort_thd(data->owner->mysql_thd, - holder->owner->mysql_thd, FALSE); - } - else - { - if (wsrep_debug) - fprintf(stderr,"WSREP wsrep_break_lock skipping BF lock conflict\n"); - return FALSE; - } - } - - /* Add our lock to the head of the wait queue */ - if (*(wait_queue->last)==wait_queue->data) - { - wait_queue->last=&data->next; - assert(wait_queue->data==0); - } - else - { - assert(wait_queue->data!=0); - wait_queue->data->prev=&data->next; - } - data->next=wait_queue->data; - data->prev=&wait_queue->data; - wait_queue->data=data; - data->cond=get_cond(); - - statistic_increment(locks_immediate,&THR_LOCK_lock); - return TRUE; - } - return FALSE; -} -#endif - static enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) { @@ -746,9 +641,6 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) enum enum_thr_lock_result result= THR_LOCK_SUCCESS; struct st_lock_list *wait_queue; enum thr_lock_type lock_type= data->type; -#ifdef WITH_WSREP - my_bool wsrep_lock_inserted= FALSE; -#endif MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */ DBUG_ENTER("thr_lock"); @@ -845,13 +737,6 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) lock but a high priority write waiting in the write_wait queue. In the latter case we should yield the lock to the writer. */ -#ifdef WITH_WSREP - if (wsrep_break_lock(data, &lock->write, &lock->read_wait)) - { - wsrep_lock_inserted= TRUE; - } -#endif - wait_queue= &lock->read_wait; } else /* Request for WRITE lock */ @@ -997,20 +882,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) (ulong) lock->read.data->owner->thread_id, data->type)); } -#ifdef WITH_WSREP - if (wsrep_break_lock(data, &lock->write, &lock->write_wait)) - { - wsrep_lock_inserted= TRUE; - } -#endif - wait_queue= &lock->write_wait; } - /* Can't get lock yet; Wait for it */ -#ifdef WITH_WSREP - if (wsrep_lock_inserted && wsrep_on(data->owner->mysql_thd)) - DBUG_RETURN(wait_for_lock(wait_queue, data, 1, lock_wait_timeout)); -#endif result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout); MYSQL_END_TABLE_LOCK_WAIT(locker); DBUG_RETURN(result); diff --git a/sql/sql_class.h b/sql/sql_class.h index d33cd1b35a4..eb9ea535862 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -615,6 +615,7 @@ typedef struct system_variables are based on the cluster size): */ ulong saved_auto_increment_increment, saved_auto_increment_offset; + ulong saved_lock_wait_timeout; #endif /* WITH_WSREP */ uint eq_range_index_dive_limit; ulong column_compression_zlib_strategy; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 0f0ef95492b..195b882a3fb 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -872,9 +872,6 @@ void wsrep_init_startup (bool sst_first) { if (wsrep_init()) unireg_abort(1); - wsrep_thr_lock_init(wsrep_thd_is_BF, wsrep_thd_bf_abort, - wsrep_debug, wsrep_convert_LOCK_to_trx, wsrep_on); - /* Pre-initialize global_system_variables.table_plugin with a dummy engine (placeholder) required during the initialization of wsrep threads (THDs). @@ -2194,6 +2191,13 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_, thd->variables.auto_increment_increment= 1; } + /* + TOI operations will ignore provided lock_wait_timeout and restore it + after operation is done. + */ + thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout; + thd->variables.lock_wait_timeout= LONG_TIMEOUT; + if (thd->variables.wsrep_on && wsrep_thd_is_local(thd)) { switch (thd->variables.wsrep_OSU_method) { @@ -2228,6 +2232,9 @@ void wsrep_to_isolation_end(THD *thd) { DBUG_ASSERT(wsrep_thd_is_local_toi(thd) || wsrep_thd_is_in_rsu(thd)); + + thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout; + if (wsrep_thd_is_local_toi(thd)) { DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI); From b1b2689f17c8c722feb2dd6648a866908040e6a7 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 23 Apr 2021 11:31:02 +0200 Subject: [PATCH 04/10] MDEV-25553 : Avoid unnecessary rollbacks with SR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch changes statement rollback for streaming replication. Previously, a statement rollback was turned into full transaction rollback in the case where the transaction had already replicated a fragment. This was introduced in the initial implementation of streaming replication due to the fact that we do not have a mechanism to perform a statement rollback on the applying side. This policy is however overly pessimistic, causing full rollbacks even in cases where a local statement rollback, would not require a statement rollback on the applying side. This happens to be case when the statement itself has not replicated any fragments. So the patch changes the condition that determines if a statement rollback should be turned into a full rollback accordingly. Reviewed-by: Jan Lindström --- .../suite/galera_3nodes_sr/disabled.def | 1 - .../suite/galera_3nodes_sr/r/GCF-609.result | 60 ++++++++++++++++++- .../suite/galera_3nodes_sr/t/GCF-609.test | 9 ++- mysql-test/suite/galera_sr/r/GCF-572.result | 26 +++++++- .../galera_sr/r/galera_sr_dupkey_error.result | 2 +- .../galera_sr/r/mysql-wsrep-bugs-900.result | 15 +++++ mysql-test/suite/galera_sr/t/GCF-572.test | 48 +++++++++++---- .../galera_sr/t/galera_sr_dupkey_error.test | 9 +-- .../galera_sr/t/mysql-wsrep-bugs-900.test | 22 +++++++ sql/log.cc | 29 --------- sql/wsrep_mysqld.h | 2 - sql/wsrep_trans_observer.h | 9 ++- 12 files changed, 176 insertions(+), 56 deletions(-) create mode 100644 mysql-test/suite/galera_sr/r/mysql-wsrep-bugs-900.result create mode 100644 mysql-test/suite/galera_sr/t/mysql-wsrep-bugs-900.test diff --git a/mysql-test/suite/galera_3nodes_sr/disabled.def b/mysql-test/suite/galera_3nodes_sr/disabled.def index 0944abd0ad5..900b27860a5 100644 --- a/mysql-test/suite/galera_3nodes_sr/disabled.def +++ b/mysql-test/suite/galera_3nodes_sr/disabled.def @@ -1,6 +1,5 @@ GCF-336 : GCF-582 : -GCF-609 : GCF-810A : GCF-810B : GCF-810C : diff --git a/mysql-test/suite/galera_3nodes_sr/r/GCF-609.result b/mysql-test/suite/galera_3nodes_sr/r/GCF-609.result index 8fe13c7e2bf..db7da93c8c0 100644 --- a/mysql-test/suite/galera_3nodes_sr/r/GCF-609.result +++ b/mysql-test/suite/galera_3nodes_sr/r/GCF-609.result @@ -1,20 +1,78 @@ +connection node_2; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_1; SET SESSION wsrep_trx_fragment_size=1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +connection node_2; SET SESSION wsrep_trx_fragment_size=1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 23000: Duplicate entry '11' for key 'PRIMARY' INSERT INTO t1 VALUES (31),(32),(33); SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; COUNT(*) = 0 0 +connection node_1; SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; COUNT(*) = 0 0 COMMIT; +connection node_2; +COMMIT; +SELECT * FROM t1; +f1 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +31 +32 +33 +connection node_1; +SELECT * FROM t1; +f1 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +31 +32 +33 DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes_sr/t/GCF-609.test b/mysql-test/suite/galera_3nodes_sr/t/GCF-609.test index fd346cf365b..210b100a9f8 100644 --- a/mysql-test/suite/galera_3nodes_sr/t/GCF-609.test +++ b/mysql-test/suite/galera_3nodes_sr/t/GCF-609.test @@ -17,7 +17,7 @@ SET SESSION wsrep_trx_fragment_size=1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); ---error ER_LOCK_DEADLOCK +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); INSERT INTO t1 VALUES (31),(32),(33); @@ -27,4 +27,11 @@ SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; COMMIT; +--connection node_2 +COMMIT; +SELECT * FROM t1; + +--connection node_1 +SELECT * FROM t1; + DROP TABLE t1; diff --git a/mysql-test/suite/galera_sr/r/GCF-572.result b/mysql-test/suite/galera_sr/r/GCF-572.result index cb4d48b3600..41ae2378a3f 100644 --- a/mysql-test/suite/galera_sr/r/GCF-572.result +++ b/mysql-test/suite/galera_sr/r/GCF-572.result @@ -1,18 +1,38 @@ connection node_2; connection node_1; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB; connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; connection node_1; SET SESSION wsrep_trx_fragment_size = 1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 DROP PRIMARY KEY; +INSERT INTO t2 VALUES (1); +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; +INSERT INTO t1 SELECT * FROM t2; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM t1; +f1 +connection node_2; +SELECT * FROM t1; +f1 +connection node_1; +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB; +connection node_1; +SET SESSION wsrep_trx_fragment_size = 1; START TRANSACTION; INSERT INTO t1 VALUES (1, 'node1'); connection node_1a; INSERT INTO t1 VALUES (5, 'node2'); connection node_1; INSERT INTO t1 VALUES (5, 'node1'); -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' SELECT * FROM t1; f1 f2 +1 node1 5 node2 SET SESSION wsrep_trx_fragment_size = 10000; START TRANSACTION; @@ -24,6 +44,7 @@ INSERT INTO t1 VALUES(15, 'node2'); connection node_1; SELECT * FROM t1; f1 f2 +1 node1 5 node2 10 node1 INSERT INTO t1 VALUES(15, 'node1'); @@ -31,6 +52,7 @@ ERROR 23000: Duplicate entry '15' for key 'PRIMARY' COMMIT; SELECT * FROM t1; f1 f2 +1 node1 5 node2 10 node1 15 node2 diff --git a/mysql-test/suite/galera_sr/r/galera_sr_dupkey_error.result b/mysql-test/suite/galera_sr/r/galera_sr_dupkey_error.result index b23b934da33..ad843c7c2c6 100644 --- a/mysql-test/suite/galera_sr/r/galera_sr_dupkey_error.result +++ b/mysql-test/suite/galera_sr/r/galera_sr_dupkey_error.result @@ -13,7 +13,7 @@ INSERT INTO t1 VALUES (REPEAT('e', 512)); INSERT INTO t1 VALUES (REPEAT('f', 512)); connection node_2; connection node_1; -INSERT INTO t1 VALUES (REPEAT('c', 512)); +INSERT INTO t1 VALUES (REPEAT('g', 1024)),(REPEAT('c', 512)); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_1; SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; diff --git a/mysql-test/suite/galera_sr/r/mysql-wsrep-bugs-900.result b/mysql-test/suite/galera_sr/r/mysql-wsrep-bugs-900.result new file mode 100644 index 00000000000..a51b5299aa2 --- /dev/null +++ b/mysql-test/suite/galera_sr/r/mysql-wsrep-bugs-900.result @@ -0,0 +1,15 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +SET SESSION wsrep_trx_fragment_size=1; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +SET SESSION wsrep_cluster_name = ' '; +ERROR HY000: Variable 'wsrep_cluster_name' is a GLOBAL variable and should be set with SET GLOBAL +INSERT INTO t1 VALUES (2); +COMMIT; +SELECT f1 AS expect_1_and_2 FROM t1; +expect_1_and_2 +1 +2 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_sr/t/GCF-572.test b/mysql-test/suite/galera_sr/t/GCF-572.test index abefb9b08f6..be77451a332 100644 --- a/mysql-test/suite/galera_sr/t/GCF-572.test +++ b/mysql-test/suite/galera_sr/t/GCF-572.test @@ -1,15 +1,43 @@ --source include/galera_cluster.inc --source include/have_innodb.inc -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB; - --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 # -# Test 1: statement rollback is not safe -# (some fragments were already replicated) +# Test 1: statement rollback is not safe. +# Statement has already replicated some fragments # +--connection node_1 +SET SESSION wsrep_trx_fragment_size = 1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 DROP PRIMARY KEY; +INSERT INTO t2 VALUES (1); +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; + +# The following INSERT .. SELECT inserts a duplicate key, +# ER_LOCK_DEADLOCK is the only possible outcome at this point. +# Notice that ER_DUP_ENTRY is NOT an option here because we were +# forced to rollback the whole transaction (not just the statement) +--error ER_LOCK_DEADLOCK +INSERT INTO t1 SELECT * FROM t2; +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; + +--connection node_1 +DROP TABLE t1; +DROP TABLE t2; + +# +# Test 2: statement rollback is safe. +# Fragments were already replicated, not in the same statement +# +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB; --connection node_1 SET SESSION wsrep_trx_fragment_size = 1; START TRANSACTION; @@ -19,20 +47,16 @@ INSERT INTO t1 VALUES (1, 'node1'); INSERT INTO t1 VALUES (5, 'node2'); --connection node_1 -# If we try to INSERT a duplicate key, ER_LOCK_DEADLOCK is the only possible -# outcome at this point. Notice that ER_DUP_ENTRY is NOT an option here -# because we were forced to rollback the whole transaction (not just the -# statement) ---error ER_LOCK_DEADLOCK +# Only the statement is rolled back, expect ER_DUP_ENTRY +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (5, 'node1'); SELECT * FROM t1; # -# Test 2: statement rollback is safe -# (no fragments have been replicated) +# Test 3: statement rollback is safe +# No fragments have been replicated # - SET SESSION wsrep_trx_fragment_size = 10000; START TRANSACTION; diff --git a/mysql-test/suite/galera_sr/t/galera_sr_dupkey_error.test b/mysql-test/suite/galera_sr/t/galera_sr_dupkey_error.test index a7aca042829..146da425d88 100644 --- a/mysql-test/suite/galera_sr/t/galera_sr_dupkey_error.test +++ b/mysql-test/suite/galera_sr/t/galera_sr_dupkey_error.test @@ -22,12 +22,13 @@ INSERT INTO t1 VALUES (REPEAT('f', 512)); --let $wait_condition = SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; --connection node_1 -# Deadlock error instead of dupkey since the transaction is SR and -# statement rollback is not safe. +# Deadlock error instead of dupkey since the transaction is SR, +# and the statement has already replicated a fragment (which +# makes statement rollback unsafe). --error ER_LOCK_DEADLOCK -INSERT INTO t1 VALUES (REPEAT('c', 512)); +INSERT INTO t1 VALUES (REPEAT('g', 1024)),(REPEAT('c', 512)); -# Confirm that the wsrep_streaming_log table is now empty, as it was a full transaction rollback +# Confirm that the wsrep_schema table is now empty, as it was a full transaction rollback --connection node_1 SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; diff --git a/mysql-test/suite/galera_sr/t/mysql-wsrep-bugs-900.test b/mysql-test/suite/galera_sr/t/mysql-wsrep-bugs-900.test new file mode 100644 index 00000000000..d534fcc5524 --- /dev/null +++ b/mysql-test/suite/galera_sr/t/mysql-wsrep-bugs-900.test @@ -0,0 +1,22 @@ +# +# Statement with no side effects causes unnecessary full rollback +# + +--source include/galera_cluster.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +SET SESSION wsrep_trx_fragment_size=1; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +# Let's cause some bogus error with a statement that +# does not cause any replication event. +# The following used to return error ER_LOCK_DEADLOCK +# and cause the entire transaction to be rolled back. +--error ER_GLOBAL_VARIABLE +SET SESSION wsrep_cluster_name = ' '; + +INSERT INTO t1 VALUES (2); +COMMIT; + +SELECT f1 AS expect_1_and_2 FROM t1; +DROP TABLE t1; \ No newline at end of file diff --git a/sql/log.cc b/sql/log.cc index 49a319eb29d..eb82100d16c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -10843,35 +10843,6 @@ void wsrep_thd_binlog_stmt_rollback(THD * thd) DBUG_VOID_RETURN; } -bool wsrep_stmt_rollback_is_safe(THD* thd) -{ - bool ret(true); - - DBUG_ENTER("wsrep_binlog_stmt_rollback_is_safe"); - - binlog_cache_mngr *cache_mngr= - (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton); - - - if (binlog_hton && cache_mngr) - { - binlog_cache_data * trx_cache = &cache_mngr->trx_cache; - if (thd->wsrep_sr().fragments_certified() > 0 && - (trx_cache->get_prev_position() == MY_OFF_T_UNDEF || - trx_cache->get_prev_position() < thd->wsrep_sr().log_position())) - { - WSREP_DEBUG("statement rollback is not safe for streaming replication" - " pre-stmt_pos: %llu, frag repl pos: %zu\n" - "Thread: %llu, SQL: %s", - trx_cache->get_prev_position(), - thd->wsrep_sr().log_position(), - thd->thread_id, thd->query()); - ret = false; - } - } - DBUG_RETURN(ret); -} - void wsrep_register_binlog_handler(THD *thd, bool trx) { DBUG_ENTER("register_binlog_handler"); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index db6910030c8..748d93c72aa 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -377,8 +377,6 @@ int wsrep_to_buf_helper( int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len); -bool wsrep_stmt_rollback_is_safe(THD* thd); - void wsrep_init_sidno(const wsrep_uuid_t&); bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index bb9bd54b02f..8157c14fcdf 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -345,11 +345,14 @@ static inline int wsrep_before_rollback(THD* thd, bool all) } if (thd->wsrep_trx().is_streaming() && - !wsrep_stmt_rollback_is_safe(thd)) + (wsrep_fragments_certified_for_stmt(thd) > 0)) { /* Non-safe statement rollback during SR multi statement - transasction. Self abort the transaction, the actual rollback - and error handling will be done in after statement phase. */ + transaction. A statement rollback is considered unsafe, if + the same statement has already replicated one or more fragments. + Self abort the transaction, the actual rollback and error + handling will be done in after statement phase. */ + WSREP_DEBUG("statement rollback is not safe for streaming replication"); wsrep_thd_self_abort(thd); ret= 0; } From cec8ea3ab546feb96076fedafc75cf964cc1ac14 Mon Sep 17 00:00:00 2001 From: Kentoku SHIBA Date: Mon, 19 Apr 2021 22:54:45 +0900 Subject: [PATCH 05/10] MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions. Fix length for getting default table name. --- .../bugfix/include/mdev_22265_deinit.inc | 7 +++++ .../spider/bugfix/include/mdev_22265_init.inc | 7 +++++ .../spider/bugfix/r/mdev_22265.result | 23 +++++++++++++++ .../mysql-test/spider/bugfix/t/mdev_22265.cnf | 2 ++ .../spider/bugfix/t/mdev_22265.test | 28 +++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc new file mode 100644 index 00000000000..ecb5622af14 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc @@ -0,0 +1,7 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc new file mode 100644 index 00000000000..6cf6b0c1f41 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc @@ -0,0 +1,7 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result new file mode 100644 index 00000000000..0331943a878 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result @@ -0,0 +1,23 @@ +for master_1 +for child2 +for child3 + +this test is for MDEV-22265 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +create table +connection master_1; +create table t2345678911234567892123456789312345678941234567895123(id int) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='host "h114", user "spider", password "spider", port "3306", database "test32738"'; + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf new file mode 100644 index 00000000000..b0853e32654 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf @@ -0,0 +1,2 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test new file mode 100644 index 00000000000..0dcb103133b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test @@ -0,0 +1,28 @@ +--source ../include/mdev_22265_init.inc +--echo +--echo this test is for MDEV-22265 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; +--enable_warnings + +--echo +--echo create table +--connection master_1 +create table t2345678911234567892123456789312345678941234567895123(id int) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='host "h114", user "spider", password "spider", port "3306", database "test32738"'; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--enable_warnings +--source ../include/mdev_22265_deinit.inc +--echo +--echo end of test From 0cc811c633d1fe5290b10fa49fad0a4b889383fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 29 Apr 2021 12:17:40 +0300 Subject: [PATCH 06/10] Update wsrep-lib --- wsrep-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsrep-lib b/wsrep-lib index a93955ddeef..f271ad0c6e3 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit a93955ddeef5989505cbb3a9f8bb124341462569 +Subproject commit f271ad0c6e3c647df83c1d5ec9cd26d77cef2337 From 42cdc37ff92b7c84abee4d9ec49c47ccbd34ba24 Mon Sep 17 00:00:00 2001 From: Kentoku SHIBA Date: Mon, 19 Apr 2021 22:54:45 +0900 Subject: [PATCH 07/10] MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions. Fix length for getting default table name. --- .../bugfix/include/mdev_22265_deinit.inc | 7 +++++ .../spider/bugfix/include/mdev_22265_init.inc | 7 +++++ .../spider/bugfix/r/mdev_22265.result | 23 +++++++++++++++ .../mysql-test/spider/bugfix/t/mdev_22265.cnf | 2 ++ .../spider/bugfix/t/mdev_22265.test | 28 +++++++++++++++++++ storage/spider/spd_table.cc | 3 +- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc new file mode 100644 index 00000000000..ecb5622af14 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_deinit.inc @@ -0,0 +1,7 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc new file mode 100644 index 00000000000..6cf6b0c1f41 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_22265_init.inc @@ -0,0 +1,7 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result new file mode 100644 index 00000000000..0331943a878 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_22265.result @@ -0,0 +1,23 @@ +for master_1 +for child2 +for child3 + +this test is for MDEV-22265 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; + +create table +connection master_1; +create table t2345678911234567892123456789312345678941234567895123(id int) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='host "h114", user "spider", password "spider", port "3306", database "test32738"'; + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf new file mode 100644 index 00000000000..b0853e32654 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.cnf @@ -0,0 +1,2 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test new file mode 100644 index 00000000000..0dcb103133b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22265.test @@ -0,0 +1,28 @@ +--source ../include/mdev_22265_init.inc +--echo +--echo this test is for MDEV-22265 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; +--enable_warnings + +--echo +--echo create table +--connection master_1 +create table t2345678911234567892123456789312345678941234567895123(id int) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='host "h114", user "spider", password "spider", port "3306", database "test32738"'; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--enable_warnings +--source ../include/mdev_22265_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 415f3be7b6c..8efa5d2551d 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -3737,7 +3737,8 @@ int spider_set_connect_info_default( if (!share->tgt_table_names[roop_count] && table_share) { DBUG_PRINT("info",("spider create default tgt_table_names")); - share->tgt_table_names_lengths[roop_count] = share->table_name_length; + share->tgt_table_names_lengths[roop_count] = + table_share->table_name.length; if ( !(share->tgt_table_names[roop_count] = spider_create_table_name_string( table_share->table_name.str, From 25fa2a68313046b638aaf1779d45d3e8c8757b07 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 30 Apr 2021 15:37:00 +0300 Subject: [PATCH 08/10] MDEV-25507 CHECK on encrypted Aria table complains about "Wrong LSN" This happens during repair when a temporary table is opened with HA_OPEN_COPY, which resets 'share->born_transactional', which the encryption code did not like. Fixed by resetting just share->now_transactional. --- .../suite/encryption/r/aria_tiny.result | 18 ++++++++++++++-- mysql-test/suite/encryption/t/aria_tiny.test | 17 +++++++++++++-- storage/maria/ma_close.c | 3 ++- storage/maria/ma_open.c | 21 ++++++++++--------- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/encryption/r/aria_tiny.result b/mysql-test/suite/encryption/r/aria_tiny.result index 7ad69878215..28f762255c4 100644 --- a/mysql-test/suite/encryption/r/aria_tiny.result +++ b/mysql-test/suite/encryption/r/aria_tiny.result @@ -1,4 +1,5 @@ -set global aria_encrypt_tables = 1; +SET @aria_encrypt= @@aria_encrypt_tables; +SET global aria_encrypt_tables=1; create table t1 (i int, key(i)) engine=aria; insert into t1 values (1); drop table t1; @@ -10,4 +11,17 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; -set global aria_encrypt_tables = 0; +# +# MDEV CHECK on encrypted Aria table complains about "Wrong LSN" +# +CREATE TABLE t1 (f DATE PRIMARY KEY) ENGINE=Aria; +INSERT INTO t1 (f) VALUES ('1995-01-01'),('2000-01-01'); +DELETE FROM t1 WHERE f = '2000-01-01'; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +set global aria_encrypt_tables=@aria_encrypt; diff --git a/mysql-test/suite/encryption/t/aria_tiny.test b/mysql-test/suite/encryption/t/aria_tiny.test index a7faba9633a..337720eec52 100644 --- a/mysql-test/suite/encryption/t/aria_tiny.test +++ b/mysql-test/suite/encryption/t/aria_tiny.test @@ -1,10 +1,12 @@ --source include/have_file_key_management_plugin.inc --source include/have_sequence.inc +SET @aria_encrypt= @@aria_encrypt_tables; +SET global aria_encrypt_tables=1; # # MDEV-8022 Assertion `rc == 0' failed in ma_encrypt on dropping an encrypted Aria table # -set global aria_encrypt_tables = 1; + create table t1 (i int, key(i)) engine=aria; insert into t1 values (1); drop table t1; @@ -24,7 +26,18 @@ alter table t1 enable keys; check table t1; drop table t1; +--echo # +--echo # MDEV CHECK on encrypted Aria table complains about "Wrong LSN" +--echo # + +CREATE TABLE t1 (f DATE PRIMARY KEY) ENGINE=Aria; +INSERT INTO t1 (f) VALUES ('1995-01-01'),('2000-01-01'); +DELETE FROM t1 WHERE f = '2000-01-01'; +OPTIMIZE TABLE t1; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; + # # Cleanup # -set global aria_encrypt_tables = 0; +set global aria_encrypt_tables=@aria_encrypt; diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index d2bbdd6f60a..7441e29a97b 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -179,7 +179,8 @@ int maria_close(register MARIA_HA *info) mysql_rwlock_destroy(&share->keyinfo[i].root_lock); } } - DBUG_ASSERT(share->now_transactional == share->base.born_transactional); + DBUG_ASSERT(share->now_transactional == share->base.born_transactional || + share->internal_table); /* We assign -1 because checkpoint does not need to flush (in case we have concurrent checkpoint if no then we do not need it here also) diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index d346c606c4e..db15778bc23 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -187,9 +187,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, maria_delay_key_write) share->delay_key_write=1; - if (!share->base.born_transactional) /* For transactional ones ... */ + if (!share->now_transactional) /* If not transctional table */ { - /* ... force crash if no trn given */ + /* Pagecache requires access to info->trn->rec_lsn */ _ma_set_tmp_trn_for_table(&info, &dummy_transaction_object); info.state= &share->state.state; /* Change global values by default */ } @@ -282,7 +282,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ulong *nulls_per_key_part; my_off_t key_root[HA_MAX_POSSIBLE_KEY]; ulonglong max_key_file_length, max_data_file_length; - my_bool versioning= 1; + my_bool versioning= 1, born_transactional; File data_file= -1, kfile= -1; struct ms3_st *s3_client= 0; S3_INFO *share_s3= 0; @@ -526,6 +526,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, file_version= (share->state.header.not_used == 0); if (file_version == 0) share->base.language= share->state.header.not_used; + born_transactional= share->base.born_transactional; share->state.state_length=base_pos; /* For newly opened tables we reset the error-has-been-printed flag */ @@ -560,7 +561,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, We can ignore testing uuid if STATE_NOT_MOVABLE is not set, as in this case the uuid will be set in _ma_mark_file_changed(). */ - if (share->base.born_transactional && + if (born_transactional && ((share->state.create_trid > trnman_get_max_trid() && !maria_in_recovery) || ((share->state.changed & STATE_NOT_MOVABLE) && @@ -601,7 +602,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, } /* Ensure we have space in the key buffer for transaction id's */ - if (share->base.born_transactional) + if (born_transactional) share->base.max_key_length= ALIGN_SIZE(share->base.max_key_length + MARIA_MAX_PACK_TRANSID_SIZE); @@ -700,7 +701,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, share->block_size= share->base.block_size; /* Convenience */ share->max_index_block_size= share->block_size - KEYPAGE_CHECKSUM_SIZE; - share->keypage_header= ((share->base.born_transactional ? + share->keypage_header= ((born_transactional ? LSN_STORE_SIZE + TRANSID_SIZE : 0) + KEYPAGE_KEYID_SIZE + KEYPAGE_FLAG_SIZE + KEYPAGE_USED_SIZE); @@ -723,7 +724,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, /* Calculate length to store a key + nod flag and transaction info */ keyinfo->max_store_length= (keyinfo->maxlength + share->base.key_reflength); - if (share->base.born_transactional) + if (born_transactional) keyinfo->max_store_length+= MARIA_INDEX_OVERHEAD_SIZE; /* See ma_delete.cc::underflow() */ @@ -862,9 +863,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, file for REPAIR. Don't do logging. This base information will not go to disk. */ - share->base.born_transactional= FALSE; + born_transactional= FALSE; } - if (share->base.born_transactional) + if (born_transactional) { share->page_type= PAGECACHE_LSN_PAGE; if (share->state.create_rename_lsn == LSN_NEEDS_NEW_STATE_LSNS) @@ -915,7 +916,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, } else share->page_type= PAGECACHE_PLAIN_PAGE; - share->now_transactional= share->base.born_transactional; + share->now_transactional= born_transactional; /* Use pack_reclength as we don't want to modify base.pack_recklength */ if (share->state.header.org_data_file_type == DYNAMIC_RECORD) From 29b0453653eeaab5ac6e4d58ae575325c4a1f7c8 Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 1 May 2021 16:40:55 +0300 Subject: [PATCH 09/10] Updated wsrep.variables after wsrep lib update --- mysql-test/suite/wsrep/r/variables.result | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result index 97fabd58de6..4163a4e750b 100644 --- a/mysql-test/suite/wsrep/r/variables.result +++ b/mysql-test/suite/wsrep/r/variables.result @@ -166,10 +166,10 @@ wsrep_thread_count 2 # variables SELECT COUNT(*) AS EXPECT_49 FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep%"; EXPECT_49 -49 +51 SELECT COUNT(*) AS EXPECT_49 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep%"; EXPECT_49 -49 +50 SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep%" ORDER BY VARIABLE_NAME; VARIABLE_NAME WSREP_AUTO_INCREMENT_CONTROL @@ -188,6 +188,7 @@ WSREP_DRUPAL_282555_WORKAROUND WSREP_FORCED_BINLOG_FORMAT WSREP_GTID_DOMAIN_ID WSREP_GTID_MODE +WSREP_GTID_SEQ_NO WSREP_IGNORE_APPLY_ERRORS WSREP_LOAD_DATA_SPLITTING WSREP_LOG_CONFLICTS @@ -218,6 +219,7 @@ WSREP_SST_DONOR_REJECTS_QUERIES WSREP_SST_METHOD WSREP_SST_RECEIVE_ADDRESS WSREP_START_POSITION +WSREP_STRICT_DDL WSREP_SYNC_WAIT WSREP_TRX_FRAGMENT_SIZE WSREP_TRX_FRAGMENT_UNIT @@ -269,6 +271,7 @@ WSREP_SST_DONOR_REJECTS_QUERIES WSREP_SST_METHOD WSREP_SST_RECEIVE_ADDRESS WSREP_START_POSITION +WSREP_STRICT_DDL WSREP_SYNC_WAIT WSREP_TRX_FRAGMENT_SIZE WSREP_TRX_FRAGMENT_UNIT From a61e5561412880f759e77e7fe126e1b80be7843e Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Sun, 2 May 2021 09:06:27 +0200 Subject: [PATCH 10/10] new column store 5.5.2-2 --- storage/columnstore/columnstore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/columnstore/columnstore b/storage/columnstore/columnstore index a37a46c1028..9797c53e855 160000 --- a/storage/columnstore/columnstore +++ b/storage/columnstore/columnstore @@ -1 +1 @@ -Subproject commit a37a46c10286218d9109c1832c9fcd89a90784e9 +Subproject commit 9797c53e855e190811385e99737ee6d755e7b7fb