From 8963d64ee87e92a07f1175292f5010c3a0d03090 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 26 Apr 2022 19:51:42 -0600 Subject: MDEV-28294: set default role bypasses Replicate_Wild_Ignore_Table: mysql.% Problem: ======== When replicating SET DEFAULT ROLE, the pre-update check (i.e. that in set_var_default_role::check()) tries to validate the existence of the given rules/user even when the targeted tables are ignored. When previously issued CREATE USER/ROLE commands are ignored by the replica because of the replication filtering rules, this results in an error because the targeted data does not exist. Solution: ======== Before checking that the given roles/user exist of a SET DEFAULT ROLE command, first ensure that the mysql.user and mysql.roles_mapping tables are not excluded by replication filters. Reviewed By: ============ Andrei Elkin Sergei Golubchik --- .../rpl/r/rpl_filter_set_var_missing_data.result | 55 ++++++++++++++ .../rpl/t/rpl_filter_set_var_missing_data.test | 83 ++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 mysql-test/suite/rpl/r/rpl_filter_set_var_missing_data.result create mode 100644 mysql-test/suite/rpl/t/rpl_filter_set_var_missing_data.test (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/rpl/r/rpl_filter_set_var_missing_data.result b/mysql-test/suite/rpl/r/rpl_filter_set_var_missing_data.result new file mode 100644 index 00000000000..e232edae1ed --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_filter_set_var_missing_data.result @@ -0,0 +1,55 @@ +include/master-slave.inc +[connection master] +# +# Set replica to ignore system mysql tables +connection slave; +include/stop_slave.inc +SET @@GLOBAL.replicate_wild_ignore_table="mysql.%"; +include/start_slave.inc +# +# Execute grant-based commands on primary which modify mysql system +# tables +connection master; +CREATE ROLE journalist; +CREATE USER testuser@localhost IDENTIFIED by ''; +GRANT journalist to testuser@localhost; +# +# Execute SET commands which use the previous user/role data +SET DEFAULT ROLE journalist for testuser@localhost; +SET PASSWORD for testuser@localhost= PASSWORD('123'); +include/save_master_gtid.inc +# +# Verify primary's grant tables have the correct user/role data +select count(*)=1 from mysql.user where User='testuser'; +count(*)=1 +1 +select count(*)=1 from mysql.roles_mapping where User='testuser'; +count(*)=1 +1 +# +# Ensure that the replica receives all of the primary's events without +# error +connection slave; +include/sync_with_master_gtid.inc +Last_SQL_Error = +Last_SQL_Errno = 0 +# +# Verify that the replica did not execute the master's commands +select count(*)=0 from mysql.user where User='testuser'; +count(*)=0 +1 +select count(*)=0 from mysql.roles_mapping where User='testuser'; +count(*)=0 +1 +# +# Clean up +connection master; +DROP ROLE journalist; +DROP USER testuser@localhost; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +include/stop_slave.inc +SET @@GLOBAL.replicate_wild_ignore_table=""; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_filter_set_var_missing_data.test b/mysql-test/suite/rpl/t/rpl_filter_set_var_missing_data.test new file mode 100644 index 00000000000..25efb6ed662 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_filter_set_var_missing_data.test @@ -0,0 +1,83 @@ +# +# Purpose: +# This test ensures that the SET DEFAULT ROLE and SET PASSWORD commands can +# be ignored by replica filter rules. MDEV-28294 exposed a bug in which +# SET DEFAULT ROLE would check for the existence of the given roles/user even +# when the targeted tables are ignored, resulting in errors if the targeted +# data does not exist. More specifically, when previously issued +# CREATE USER/ROLE commands are ignored by the replica because of the +# replication filtering rules, SET DEFAULT ROLE would result in an error +# because the targeted data does not exist. +# +# Methodology: +# Using a replica configured with replicate_wild_ignore_table="mysql.%", +# execute SET DEFAULT ROLE and SET PASSWORD on the primary and ensure that the +# replica neither errors nor executes the commands which the primary sends. +# +# References: +# MDEV-28294: set default role bypasses Replicate_Wild_Ignore_Table: mysql.% +# + +source include/master-slave.inc; +source include/have_binlog_format_mixed.inc; + +--echo # +--echo # Set replica to ignore system mysql tables +connection slave; +let $old_filter= query_get_value(SHOW SLAVE STATUS, Replicate_Wild_Ignore_Table, 1); +source include/stop_slave.inc; +SET @@GLOBAL.replicate_wild_ignore_table="mysql.%"; +source include/start_slave.inc; + +--echo # +--echo # Execute grant-based commands on primary which modify mysql system +--echo # tables +connection master; +CREATE ROLE journalist; +CREATE USER testuser@localhost IDENTIFIED by ''; +GRANT journalist to testuser@localhost; + +--echo # +--echo # Execute SET commands which use the previous user/role data +SET DEFAULT ROLE journalist for testuser@localhost; +SET PASSWORD for testuser@localhost= PASSWORD('123'); +--source include/save_master_gtid.inc + +--echo # +--echo # Verify primary's grant tables have the correct user/role data +select count(*)=1 from mysql.user where User='testuser'; +select count(*)=1 from mysql.roles_mapping where User='testuser'; + +--echo # +--echo # Ensure that the replica receives all of the primary's events without +--echo # error +connection slave; +--source include/sync_with_master_gtid.inc +let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1); +--echo Last_SQL_Error = $error +let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); +--echo Last_SQL_Errno = $errno + +--echo # +--echo # Verify that the replica did not execute the master's commands +select count(*)=0 from mysql.user where User='testuser'; +select count(*)=0 from mysql.roles_mapping where User='testuser'; + +--echo # +--echo # Clean up + +# The master has to drop the role/user combination while the slave still has +# its filters active; otherwise, the slave would try to drop users/roles that +# were never replicated. +--connection master +DROP ROLE journalist; +DROP USER testuser@localhost; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc +source include/stop_slave.inc; +--eval SET @@GLOBAL.replicate_wild_ignore_table="$old_filter" +source include/start_slave.inc; + +--source include/rpl_end.inc -- cgit v1.2.1 From 8ff10969996a5349e906fab44b45c6e3ec53eea0 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Wed, 24 Aug 2022 17:06:57 +0300 Subject: MDEV-29081 trx_t::lock.was_chosen_as_deadlock_victim race in lock_wait_end() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue is that trx_t::lock.was_chosen_as_deadlock_victim can be reset before the transaction check it and set trx_t::error_state. The fix is to reset trx_t::lock.was_chosen_as_deadlock_victim only in trx_t::commit_in_memory(), which is invoked on full rollback. There is also no need to have separate bit in trx_t::lock.was_chosen_as_deadlock_victim to flag transaction it was chosen as a victim of Galera conflict resolution, the same variable can be used for both cases except debug build. For debug build we need to distinguish deadlock and Galera's abort victims for debug checks. Also there is no need to check for deadlock in lock_table_enqueue_waiting() for Galera as the coresponding check presents in lock_wait(). Local variable "error_state" in lock_wait() was replaced with trx->error_state, because before the replace lock_sys_t::cancel(trx, lock) and lock_sys.deadlock_check() could change trx->error_state, which then could be overwritten with the local "error_state" variable value. The lock_wait_suspend_thread_enter DEBUG_SYNC point name is misleading, because lock_wait_suspend_thread was eliminated in e71e613. It was renamed to lock_wait_start. Reviewed by: Marko Mäkelä, Jan Lindström. --- .../r/galera_FK_duplicate_client_insert.result | 40 ++++---- .../t/galera_FK_duplicate_client_insert.test | 4 +- .../suite/innodb/r/cursor-restore-locking.result | 4 +- .../suite/innodb/r/deadlock_victim_race.result | 42 +++++++++ mysql-test/suite/innodb/r/update-cascade.result | 8 +- .../suite/innodb/t/cursor-restore-locking.test | 6 +- .../suite/innodb/t/deadlock_victim_race.test | 102 +++++++++++++++++++++ mysql-test/suite/innodb/t/update-cascade.test | 8 +- 8 files changed, 179 insertions(+), 35 deletions(-) create mode 100644 mysql-test/suite/innodb/r/deadlock_victim_race.result create mode 100644 mysql-test/suite/innodb/t/deadlock_victim_race.test (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result b/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result index 5ae577a6323..b40c57c5d90 100644 --- a/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result +++ b/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result @@ -14,7 +14,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -32,7 +32,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -50,7 +50,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -68,7 +68,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -86,7 +86,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -104,7 +104,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -122,7 +122,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -140,7 +140,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -158,7 +158,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -176,7 +176,7 @@ connection node_1_u; begin; update user set j = j + 1 WHERE id > 0; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; insert into user_session(id,fk1,fk2) values (2, 2, 2); connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -202,7 +202,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -220,7 +220,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -238,7 +238,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -256,7 +256,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -274,7 +274,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -292,7 +292,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -310,7 +310,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -328,7 +328,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -346,7 +346,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; @@ -364,7 +364,7 @@ connection node_1_u; begin; execute upd; connection node_1_i; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; +set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; execute ins1; connection node_1; set debug_sync='now WAIT_FOR ins_waiting'; diff --git a/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test index 02322fc02ec..6dd1fee1d4e 100644 --- a/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test +++ b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test @@ -72,7 +72,7 @@ while($counter > 0) update user set j = j + 1 WHERE id > 0; --connection node_1_i - set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; + set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; send insert into user_session(id,fk1,fk2) values (2, 2, 2); --connection node_1 @@ -126,7 +126,7 @@ while($counter > 0) #update user set j = j + 1 WHERE id > 0; --connection node_1_i - set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins'; + set debug_sync='lock_wait_start SIGNAL ins_waiting WAIT_FOR cont_ins'; send execute ins1; --connection node_1 diff --git a/mysql-test/suite/innodb/r/cursor-restore-locking.result b/mysql-test/suite/innodb/r/cursor-restore-locking.result index bc1127f57b3..beeb5a87844 100644 --- a/mysql-test/suite/innodb/r/cursor-restore-locking.result +++ b/mysql-test/suite/innodb/r/cursor-restore-locking.result @@ -7,12 +7,12 @@ SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_m DELETE FROM t WHERE b = 20; connect con_ins_1,localhost,root,,; SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished'; -SET DEBUG_SYNC = 'lock_wait_suspend_thread_enter SIGNAL first_ins_locked'; +SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked'; SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont'; INSERT INTO t VALUES(10, 20); connect con_del_2,localhost,root,,; SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked'; -SET DEBUG_SYNC = 'lock_wait_suspend_thread_enter SIGNAL second_del_locked'; +SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked'; DELETE FROM t WHERE b = 20; connection default; SET DEBUG_SYNC = 'now WAIT_FOR second_del_locked'; diff --git a/mysql-test/suite/innodb/r/deadlock_victim_race.result b/mysql-test/suite/innodb/r/deadlock_victim_race.result new file mode 100644 index 00000000000..9a7ef51ef24 --- /dev/null +++ b/mysql-test/suite/innodb/r/deadlock_victim_race.result @@ -0,0 +1,42 @@ +CREATE TABLE t (a int PRIMARY KEY, b int) engine = InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY) engine = InnoDB; +INSERT INTO t VALUES (10, 10), (20, 20), (30, 30); +INSERT INTO t2 VALUES (10), (20), (30); +BEGIN; +SELECT * FROM t WHERE a = 20 FOR UPDATE; +a b +20 20 +connect con_2,localhost,root,,; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SET DEBUG_SYNC = 'lock_trx_handle_wait_enter SIGNAL upd_locked WAIT_FOR upd_cont EXECUTE 2'; +UPDATE t SET b = 100; +connect con_3,localhost,root,,; +BEGIN; +UPDATE t2 SET a = a + 100; +SELECT * FROM t WHERE a = 30 FOR UPDATE; +a b +30 30 +SET DEBUG_SYNC='now WAIT_FOR upd_locked'; +SET DEBUG_SYNC = 'lock_wait_start SIGNAL sel_locked'; +SELECT * FROM t WHERE a = 20 FOR UPDATE; +connection default; +SET DEBUG_SYNC='now WAIT_FOR sel_locked'; +ROLLBACK; +SET DEBUG_SYNC='now SIGNAL upd_cont'; +SET innodb_lock_wait_timeout=1; +SET DEBUG_SYNC="now WAIT_FOR upd_locked"; +SET DEBUG_SYNC="lock_wait_end SIGNAL upd_cont"; +SELECT * FROM t WHERE a = 10 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con_3; +a b +20 20 +connection con_2; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +disconnect con_3; +disconnect con_2; +connection default; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t; +DROP TABLE t2; diff --git a/mysql-test/suite/innodb/r/update-cascade.result b/mysql-test/suite/innodb/r/update-cascade.result index a3c8fed931e..21d8f11e1cb 100644 --- a/mysql-test/suite/innodb/r/update-cascade.result +++ b/mysql-test/suite/innodb/r/update-cascade.result @@ -38,7 +38,7 @@ select f1, f2 from t2 for update; f1 f2 1 2 connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; update t1 set f1 = 10 where f1 = 2; connection con1; set debug_sync='now WAIT_FOR upd_waiting'; @@ -97,7 +97,7 @@ select f1, f2 from t2 for update; f1 f2 1 91 connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; update t1 set f2 = 28 where f2 = 91; connection con1; set debug_sync='now WAIT_FOR upd_waiting'; @@ -164,7 +164,7 @@ select f1 from t3 for update; f1 2 connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; update t1 set f1 = 10 where f1 = 2; connection con1; set debug_sync='now WAIT_FOR upd_waiting'; @@ -253,7 +253,7 @@ select f1 from t3 for update; f1 2 connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; update t1 set f2 = 28 where f2 = 91; connection con1; set debug_sync='now WAIT_FOR upd_waiting'; diff --git a/mysql-test/suite/innodb/t/cursor-restore-locking.test b/mysql-test/suite/innodb/t/cursor-restore-locking.test index d032d8a8def..a398768fc66 100644 --- a/mysql-test/suite/innodb/t/cursor-restore-locking.test +++ b/mysql-test/suite/innodb/t/cursor-restore-locking.test @@ -16,19 +16,19 @@ SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_m --connect(con_ins_1,localhost,root,,) SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished'; # It's supposed the following INSERT will be suspended just after -# lock_wait_suspend_thread_enter syncpoint, and will be awaken +# lock_wait_start syncpoint, and will be awaken # after the previous DELETE commits. ib_after_row_insert will be executed # after the INSERT is woken up. The previous DELETE will wait for # first_del_cont signal before commit, and this signal will be sent later. # So it's safe to use two signals in a row here, it's guaranted the first # signal will be received before the second signal is sent. -SET DEBUG_SYNC = 'lock_wait_suspend_thread_enter SIGNAL first_ins_locked'; +SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked'; SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont'; --send INSERT INTO t VALUES(10, 20) --connect(con_del_2,localhost,root,,) SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked'; -SET DEBUG_SYNC = 'lock_wait_suspend_thread_enter SIGNAL second_del_locked'; +SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked'; ############################################################################### # This DELETE is locked by the previous DELETE, after that DELETE is # committed, it will still be locked by the next INSERT on delete-marked diff --git a/mysql-test/suite/innodb/t/deadlock_victim_race.test b/mysql-test/suite/innodb/t/deadlock_victim_race.test new file mode 100644 index 00000000000..3c9dd15fb4d --- /dev/null +++ b/mysql-test/suite/innodb/t/deadlock_victim_race.test @@ -0,0 +1,102 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/count_sessions.inc + +CREATE TABLE t (a int PRIMARY KEY, b int) engine = InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY) engine = InnoDB; + +INSERT INTO t VALUES (10, 10), (20, 20), (30, 30); +INSERT INTO t2 VALUES (10), (20), (30); + +BEGIN; # trx 1 +SELECT * FROM t WHERE a = 20 FOR UPDATE; +# Locking order: +# (10,10) (20,20) (30,30) +# ^ +# trx 1 + +--connect(con_2,localhost,root,,) +# RC is neccessary to do semi-consistent read +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; # trx 2 +# The first time it will be hit on trying to lock (20,20), the second hit +# will be on (30,30). +SET DEBUG_SYNC = 'lock_trx_handle_wait_enter SIGNAL upd_locked WAIT_FOR upd_cont EXECUTE 2'; +# We must not modify primary key fields to cause rr_sequential() read record +# function choosing in mysql_update(), i.e. both query_plan.using_filesort and +# query_plan.using_io_buffer must be false during init_read_record() call. +--send UPDATE t SET b = 100 + +--connect(con_3,localhost,root,,) +BEGIN; # trx 3 +# The following update is necessary to increase the transaction weight, which is +# calculated as the number of locks + the number of undo records during deadlock +# report. Victim's transaction should have minimum weight. We need trx 2 to be +# choosen as victim, that's why we need to increase the current transaction +# weight. +UPDATE t2 SET a = a + 100; +SELECT * FROM t WHERE a = 30 FOR UPDATE; +SET DEBUG_SYNC='now WAIT_FOR upd_locked'; +# Locking queue: +# (10,10) (20,20) (30,30) +# ^ ^ ^ +# trx 2 trx 1 trx 3 +# trx 2 (waiting for 1) + +SET DEBUG_SYNC = 'lock_wait_start SIGNAL sel_locked'; +--send SELECT * FROM t WHERE a = 20 FOR UPDATE +--connection default +SET DEBUG_SYNC='now WAIT_FOR sel_locked'; +# Locking queue: +# (10,10) (20,20) (30,30) +# ^ ^ ^ +# trx 2 trx 1 trx 3 +# trx 2 (waiting for 1) +# trx 3 (waiting for 1) +# +# Note trx 1 must grant lock to trx2 before trx 2 checks the lock state in +# lock_trx_handle_wait(), i.e. the function must return DB_SUCCESS, that's why +# the following ROLLBACK must be executed before sending upd_cont signal. +ROLLBACK; +SET DEBUG_SYNC='now SIGNAL upd_cont'; + +SET innodb_lock_wait_timeout=1; +SET DEBUG_SYNC="now WAIT_FOR upd_locked"; +# Locking queue: +# (10,10) (20,20) (30,30) +# ^ ^ ^ +# trx 2 trx 2 trx 3 +# trx 3 (waiting for 2) trx 2 (waiting for 3) +# +# Deadlock happened after trx 1 granted lock to trx 2, and trx2 continued +# sequential read (with rr_sequential() read record function), and requested +# lock on (30,30). But the deadlock has not been determined yet. + +SET DEBUG_SYNC="lock_wait_end SIGNAL upd_cont"; +--error ER_LOCK_WAIT_TIMEOUT +# The deadlock will be determined in lock_wait() after lock wait timeout +# expired. +SELECT * FROM t WHERE a = 10 FOR UPDATE; + +--connection con_3 +--reap + +--connection con_2 +# As lock_trx_handle_wait() wrongly returned DB_SUCCESS instead of +# DB_DEADLOCK, row_search_mvcc() of trx 2 behaves so as if (30,30) was locked. +# But the waiting(for trx 3) lock was cancelled by deadlock checker after +# trx 2 was choosen as a victim (see lock_cancel_waiting_and_release() call +# from Deadlock::report() for details). The try to update non-locked record +# will cause assertion if the bug is not fixed. +--error ER_LOCK_DEADLOCK +--reap + +--disconnect con_3 +--disconnect con_2 + +--connection default +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t; +DROP TABLE t2; + +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/update-cascade.test b/mysql-test/suite/innodb/t/update-cascade.test index de8294703b4..69e81ac4a2f 100644 --- a/mysql-test/suite/innodb/t/update-cascade.test +++ b/mysql-test/suite/innodb/t/update-cascade.test @@ -28,7 +28,7 @@ start transaction; select f1, f2 from t2 for update; connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; send update t1 set f1 = 10 where f1 = 2; connection con1; @@ -72,7 +72,7 @@ start transaction; select f1, f2 from t2 for update; connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; send update t1 set f2 = 28 where f2 = 91; connection con1; @@ -120,7 +120,7 @@ start transaction; select f1 from t3 for update; connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; send update t1 set f1 = 10 where f1 = 2; connection con1; @@ -183,7 +183,7 @@ start transaction; select f1 from t3 for update; connection default; -set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd'; +set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd'; send update t1 set f2 = 28 where f2 = 91; connection con1; -- cgit v1.2.1 From 79b58f1ca893b8affc5075d0a548563d376cd481 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 30 Jul 2022 00:11:08 +1000 Subject: MDEV-23607 MariaBackup - align required GRANTS to cmd options Since the 10.5 split of the privileges, the required GRANTs for various mariabackup operations has changed. In the addition of tests, a number of mappings where incorrect: The option --lock-ddl-per-table didn't require connection admin. The option --safe-slave-backup requires SLAVE MONITOR even without the --no-lock option. --- mysql-test/suite/mariabackup/backup_grants.result | 8 +++ mysql-test/suite/mariabackup/backup_grants.test | 59 ++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/mariabackup/backup_grants.result b/mysql-test/suite/mariabackup/backup_grants.result index ed793e7ff1a..56899f8d9c0 100644 --- a/mysql-test/suite/mariabackup/backup_grants.result +++ b/mysql-test/suite/mariabackup/backup_grants.result @@ -3,4 +3,12 @@ FOUND 1 /missing required privilege RELOAD/ in backup.log FOUND 1 /missing required privilege PROCESS/ in backup.log FOUND 1 /GRANT USAGE ON/ in backup.log GRANT RELOAD, PROCESS on *.* to backup@localhost; +NOT FOUND /missing required privilege REPLICA MONITOR/ in backup.log +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; +GRANT CONNECTION ADMIN ON *.* TO backup@localhost; +FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log +NOT FOUND /missing required privilege REPLICA MONITOR/ in backup.log +GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; +GRANT REPLICA MONITOR ON *.* TO backup@localhost; DROP USER backup@localhost; diff --git a/mysql-test/suite/mariabackup/backup_grants.test b/mysql-test/suite/mariabackup/backup_grants.test index eadeedd9b5f..894ae73aeb9 100644 --- a/mysql-test/suite/mariabackup/backup_grants.test +++ b/mysql-test/suite/mariabackup/backup_grants.test @@ -25,7 +25,62 @@ GRANT RELOAD, PROCESS on *.* to backup@localhost; --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --target-dir=$targetdir; --enable_result_log +rmdir $targetdir; -DROP USER backup@localhost; -# Cleanup +# MDEV-23607 Warning: missing required privilege REPLICATION CLIENT +# --slave-info and galera info require REPLICA MONITOR +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +--enable_result_log +rmdir $targetdir; + +--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--source include/search_pattern_in_file.inc + +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; +REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; + +# TODO need a query that would delay a BACKUP STAGE START/ BACKUP STAGE BLOCK_COMMIT longer than the kill-long-queries-timeout +#--send SELECT SLEEP(9) kill_me +## kill-long-query-type=(not empty) requires CONNECTION ADMIN +#--disable_result_log +#error 1; +#--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=all --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +#--reap +#--enable_result_log +#rmdir $targetdir; +# +#--let SEARCH_PATTERN= missing required privilege CONNECTION ADMIN +#--source include/search_pattern_in_file.inc + +GRANT CONNECTION ADMIN ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +# --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +--enable_result_log rmdir $targetdir; + +--let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--source include/search_pattern_in_file.inc + +GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +DROP USER backup@localhost; -- cgit v1.2.1 From 827b049e1e7df204feb744a270b4dca619a61de1 Mon Sep 17 00:00:00 2001 From: tmokmss Date: Sun, 5 Jun 2022 08:04:18 +0000 Subject: MDEV-18873 Server crashes in Compare_identifiers::operator or in my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name empty identifier specified as `` ends up with a NULL LEX_CSTRING::str in lexer. This is not considered correct in upper layers, for example in Compare_identifiers::operator(). Empty column name is usually avoided by a check_column_name() call while parsing, and period name matches the column name completely. Hence, this fix uses the mentioned call for verification, too. --- mysql-test/suite/period/r/alter.result | 14 ++++++++++++++ mysql-test/suite/period/t/alter.test | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/period/r/alter.result b/mysql-test/suite/period/r/alter.result index a6466c8944b..875dab93b68 100644 --- a/mysql-test/suite/period/r/alter.result +++ b/mysql-test/suite/period/r/alter.result @@ -190,3 +190,17 @@ alter table t1 add primary key(x, s, e); ERROR 23000: Duplicate entry '1-2020-03-01-2020-03-02' for key 'PRIMARY' alter table t1 add system versioning; drop table t1; +# +# MDEV-18873 Server crashes in Compare_identifiers::operator or in +# my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name +# +alter table t add period if not exists for `` (s,e); +ERROR 42000: Incorrect column name '' +create table t(s DATE, e DATE); +alter table t add period if not exists for `` (s,e); +ERROR 42000: Incorrect column name '' +alter table t add period if not exists for ` ` (s,e); +ERROR 42000: Incorrect column name ' ' +create table t2 (period for `` (s,e)) select * from t; +ERROR 42000: Incorrect column name '' +drop table t; diff --git a/mysql-test/suite/period/t/alter.test b/mysql-test/suite/period/t/alter.test index 3fa3c5c87d5..2a82f74b670 100644 --- a/mysql-test/suite/period/t/alter.test +++ b/mysql-test/suite/period/t/alter.test @@ -151,3 +151,26 @@ alter table t1 add system versioning; # cleanup drop table t1; + +--echo # +--echo # MDEV-18873 Server crashes in Compare_identifiers::operator or in +--echo # my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name +--echo # + +# When there is no table defined. +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for `` (s,e); + +# When there is an actual table. +create table t(s DATE, e DATE); +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for `` (s,e); + +# When the last character is space +--error ER_WRONG_COLUMN_NAME +alter table t add period if not exists for ` ` (s,e); + +# Create table with an empty period name +--error ER_WRONG_COLUMN_NAME +create table t2 (period for `` (s,e)) select * from t; +drop table t; -- cgit v1.2.1 From b9c2ae505dc3f57358c1b0cca7feb79e768e84fc Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 26 Aug 2022 14:25:04 +0400 Subject: MDEV-29356 Assertion `0' failed in Type_handler_row::Item_save_in_field on INSERT --- mysql-test/suite/compat/oracle/r/sp-row.result | 8 ++++---- mysql-test/suite/compat/oracle/t/sp-row.test | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/compat/oracle/r/sp-row.result b/mysql-test/suite/compat/oracle/r/sp-row.result index 7fd986a71c8..c978d4be983 100644 --- a/mysql-test/suite/compat/oracle/r/sp-row.result +++ b/mysql-test/suite/compat/oracle/r/sp-row.result @@ -24,7 +24,7 @@ RETURN a; END; $$ SELECT f1(ROW(10,20)); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Cannot cast 'row' as 'int' in assignment of `f1(ROW(10,20))` DROP FUNCTION f1; # # ROW as an SP parameter @@ -261,7 +261,7 @@ SELECT f1(a); END; $$ CALL p1(); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Cannot cast 'row' as 'int' in assignment of `a` DROP PROCEDURE p1; DROP FUNCTION f1; CREATE FUNCTION f1(a INT) RETURN INT @@ -278,7 +278,7 @@ SELECT f1(a); END; $$ CALL p1(); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Cannot cast 'row' as 'int' in assignment of `a` DROP PROCEDURE p1; DROP FUNCTION f1; # @@ -332,7 +332,7 @@ RETURN rec; END; $$ SELECT f1(10); -ERROR 21000: Operand should contain 1 column(s) +ERROR HY000: Cannot cast 'row' as 'int' in assignment of `f1(10)` DROP FUNCTION f1; # # Using the entire ROW in SELECT..CREATE diff --git a/mysql-test/suite/compat/oracle/t/sp-row.test b/mysql-test/suite/compat/oracle/t/sp-row.test index ebd0a2a2137..c7658c76838 100644 --- a/mysql-test/suite/compat/oracle/t/sp-row.test +++ b/mysql-test/suite/compat/oracle/t/sp-row.test @@ -35,7 +35,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION SELECT f1(ROW(10,20)); DROP FUNCTION f1; @@ -334,7 +334,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION CALL p1(); DROP PROCEDURE p1; DROP FUNCTION f1; @@ -355,7 +355,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION CALL p1(); DROP PROCEDURE p1; DROP FUNCTION f1; @@ -427,7 +427,7 @@ BEGIN END; $$ DELIMITER ;$$ ---error ER_OPERAND_COLUMNS +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION SELECT f1(10); DROP FUNCTION f1; -- cgit v1.2.1 From 0d1de5e1d19f1e96058ab5948e184f22e7bdd908 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Sun, 28 Aug 2022 21:23:28 +0300 Subject: MDEV-29403 innodb.innodb_sys_semaphore_waits fails with wrong errno 5014 take into account C/C specific CR_ERR_NET_WRITE error --- mysql-test/suite/innodb/t/innodb_sys_semaphore_waits.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits.test b/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits.test index a0b9fc626f3..29ff3f69ed7 100644 --- a/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits.test +++ b/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits.test @@ -78,10 +78,10 @@ let $counter= 80; let $mysql_errno= 0; while (!$mysql_errno) { - --error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013 + --error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013,5014 show status; - --error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013 + --error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013,5014 select * from information_schema.innodb_sys_semaphore_waits; dec $counter; -- cgit v1.2.1 From b260903832456dcad882e01a10cdcd48dfd2b0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 30 Aug 2022 10:59:31 +0300 Subject: MDEV-29258 Failing assertion for name length on RENAME TABLE trx_undo_page_report_rename(): Use the correct maximum length of a table name. Both the database name and the table name can be up to NAME_CHAR_LEN (64 characters) times 5 bytes per character in the my_charset_filename encoding. They are not encoded in UTF-8! fil_op_write_log(): Reserve the correct amount of log buffer for a rename operation. The file name will be appended by mlog_catenate_string(). rename_file_ext(): Reserve a large enough buffer for the file names. --- .../suite/innodb/r/foreign_key_not_windows.result | 9 ++++++++- mysql-test/suite/innodb/t/foreign_key_not_windows.test | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/innodb/r/foreign_key_not_windows.result b/mysql-test/suite/innodb/r/foreign_key_not_windows.result index 764ba911214..0dcc3d46bb1 100644 --- a/mysql-test/suite/innodb/r/foreign_key_not_windows.result +++ b/mysql-test/suite/innodb/r/foreign_key_not_windows.result @@ -11,6 +11,13 @@ CREATE TABLE `d255`.`_##################################################` ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/_@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023 CREATE TABLE `d255`.`##################################################` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +# +# MDEV-29258 Failing assertion for name length on RENAME TABLE +# +CREATE TABLE `d255`.`d245` (x INT) ENGINE=InnoDB; +DROP TABLE `d255`.`d250`; +RENAME TABLE `d250#`.`d245` TO `d250#`.`d250`; +RENAME TABLE `d255`.`d250` TO a; DROP DATABASE `d255`; -DROP TABLE t; +DROP TABLE a,t; # End of 10.3 tests diff --git a/mysql-test/suite/innodb/t/foreign_key_not_windows.test b/mysql-test/suite/innodb/t/foreign_key_not_windows.test index 7ad3723d5de..0e1e25d64b3 100644 --- a/mysql-test/suite/innodb/t/foreign_key_not_windows.test +++ b/mysql-test/suite/innodb/t/foreign_key_not_windows.test @@ -38,8 +38,23 @@ eval CREATE TABLE `$d255`.`_$d250` --replace_result $d255 d255 eval CREATE TABLE `$d255`.`$d250` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + +--echo # +--echo # MDEV-29258 Failing assertion for name length on RENAME TABLE +--echo # + +let $d245=-------------------------------------------------; +--replace_result $d245 d245 $d255 d255 +eval CREATE TABLE `$d255`.`$d245` (x INT) ENGINE=InnoDB; +--replace_result $d250 d250 $d255 d255 +eval DROP TABLE `$d255`.`$d250`; + +--replace_result $d245 d245 $d250 d250 d255 d255 +eval RENAME TABLE `$d255`.`$d245` TO `$d255`.`$d250`; +--replace_result $d250 d250 $d255 d255 +eval RENAME TABLE `$d255`.`$d250` TO a; --replace_result $d255 d255 eval DROP DATABASE `$d255`; -DROP TABLE t; +DROP TABLE a,t; --echo # End of 10.3 tests -- cgit v1.2.1 From 422f3204efbbb27be9ad95355f69636114e7f907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 30 Aug 2022 12:02:56 +0300 Subject: MDEV-29409 Buffer overflow in my_wc_mb_filename() on RENAME TABLE dict_table_rename_in_cache(), dict_table_get_highest_foreign_id(): Reserve sufficient space for the fkid[] buffer, and ensure that the fkid[] will be NUL-terminated. The fkid[] must accommodate both the database name (which is already encoded in my_charset_filename) and the constraint name (which must be converted to my_charset_filename) so that we can check if it is in the format databasename/tablename_ibfk_1 (all encoded in my_charset_filename). --- .../suite/innodb/r/foreign_key_not_windows.result | 10 +++++++++- .../suite/innodb/t/foreign_key_not_windows.test | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/innodb/r/foreign_key_not_windows.result b/mysql-test/suite/innodb/r/foreign_key_not_windows.result index 0dcc3d46bb1..aaff06f8d68 100644 --- a/mysql-test/suite/innodb/r/foreign_key_not_windows.result +++ b/mysql-test/suite/innodb/r/foreign_key_not_windows.result @@ -18,6 +18,14 @@ CREATE TABLE `d255`.`d245` (x INT) ENGINE=InnoDB; DROP TABLE `d255`.`d250`; RENAME TABLE `d250#`.`d245` TO `d250#`.`d250`; RENAME TABLE `d255`.`d250` TO a; -DROP DATABASE `d255`; DROP TABLE a,t; +# +# MDEV-29409 Buffer overflow in my_wc_mb_filename() on RENAME TABLE +# +CREATE TABLE `d255`.t(a INT PRIMARY KEY)ENGINE=InnoDB; +CREATE TABLE `d255`.u(a INT PRIMARY KEY, +CONSTRAINT `d320` FOREIGN KEY (a) REFERENCES `d255`.t (a)) ENGINE=InnoDB; +RENAME TABLE `d255`.u TO u; +DROP TABLE u; +DROP DATABASE `d255`; # End of 10.3 tests diff --git a/mysql-test/suite/innodb/t/foreign_key_not_windows.test b/mysql-test/suite/innodb/t/foreign_key_not_windows.test index 0e1e25d64b3..e5f42a0ddab 100644 --- a/mysql-test/suite/innodb/t/foreign_key_not_windows.test +++ b/mysql-test/suite/innodb/t/foreign_key_not_windows.test @@ -54,7 +54,24 @@ eval RENAME TABLE `$d255`.`$d245` TO `$d255`.`$d250`; --replace_result $d250 d250 $d255 d255 eval RENAME TABLE `$d255`.`$d250` TO a; --replace_result $d255 d255 -eval DROP DATABASE `$d255`; DROP TABLE a,t; +--echo # +--echo # MDEV-29409 Buffer overflow in my_wc_mb_filename() on RENAME TABLE +--echo # + +let $d225=#############################################; +let $d320=################################################################; + +--replace_result $d255 d255 +eval CREATE TABLE `$d255`.t(a INT PRIMARY KEY)ENGINE=InnoDB; +--replace_result $d255 d255 $d320 d320 +eval CREATE TABLE `$d255`.u(a INT PRIMARY KEY, +CONSTRAINT `$d320` FOREIGN KEY (a) REFERENCES `$d255`.t (a)) ENGINE=InnoDB; +--replace_result $d255 d255 +eval RENAME TABLE `$d255`.u TO u; +DROP TABLE u; +--replace_result $d255 d255 +eval DROP DATABASE `$d255`; + --echo # End of 10.3 tests -- cgit v1.2.1 From 57739ae94a4af580c62bbc87d364fa002c5dbe04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 30 Aug 2022 12:03:58 +0300 Subject: MDEV-13888: innodb_fts.innodb_fts_plugin failed Add ORDER BY to make the test deterministic. Add FLUSH TABLES to avoid crash recovery warnings about the table mysql.plugin. This tends to occur on Valgrind, where the server shutdown could presumably time out, resulting in a forced kill. --- .../suite/innodb_fts/r/innodb_fts_plugin.result | 36 ++++++++++++---------- .../suite/innodb_fts/t/innodb_fts_plugin.test | 24 +++++++++------ 2 files changed, 35 insertions(+), 25 deletions(-) (limited to 'mysql-test/suite') diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result b/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result index cec88f14b26..e636b30852b 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result @@ -1,4 +1,5 @@ INSTALL PLUGIN simple_parser SONAME 'mypluglib'; +FLUSH TABLES; # Test Part 1: Grammar Test CREATE TABLE articles ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -31,7 +32,7 @@ INSERT INTO articles (title, body) VALUES ('1001 MySQL Tricks','How to use full-text search engine'), ('Go MySQL Tricks','How to use full text search engine'); SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('mysql'); +MATCH(title, body) AGAINST('mysql') ORDER BY id; id title body 1 MySQL Tutorial DBMS stands for MySQL DataBase ... 2 How To Use MySQL Well After you went through a ... @@ -68,7 +69,7 @@ INSERT INTO articles (title, body) VALUES ('Go MySQL Tricks','How to use full text search engine'); ALTER TABLE articles ADD FULLTEXT INDEX (title, body) WITH PARSER simple_parser; SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('mysql'); +MATCH(title, body) AGAINST('mysql') ORDER BY id; id title body 1 MySQL Tutorial DBMS stands for MySQL DataBase ... 2 How To Use MySQL Well After you went through a ... @@ -88,21 +89,23 @@ MATCH(title, body) AGAINST('full text'); id title body 5 Go MySQL Tricks How to use full text search engine SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION); +MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION) +ORDER BY id; id title body -4 1001 MySQL Tricks How to use full-text search engine -5 Go MySQL Tricks How to use full text search engine -2 How To Use MySQL Well After you went through a ... 1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... 3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION); +MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION) +ORDER BY id; id title body -5 Go MySQL Tricks How to use full text search engine -4 1001 MySQL Tricks How to use full-text search engine -2 How To Use MySQL Well After you went through a ... 1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... 3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine SELECT * FROM articles WHERE MATCH(title, body) AGAINST('"mysql database"' IN BOOLEAN MODE); id title body @@ -135,27 +138,27 @@ INSERT INTO articles (title, body) VALUES ('1001 MySQL Tricks','How to use full-text search engine'), ('Go MariaDB Tricks','How to use full text search engine'); SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('MySQL'); +MATCH(title, body) AGAINST('MySQL') ORDER BY id; id title body 6 MySQL Tutorial DBMS stands for MySQL DataBase ... 7 How To Use MySQL Well After you went through a ... 8 Optimizing MySQL In this tutorial we will show ... 9 1001 MySQL Tricks How to use full-text search engine SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('tutorial'); +MATCH(title, body) AGAINST('tutorial') ORDER BY id; id title body 6 MySQL Tutorial DBMS stands for MySQL DataBase ... 8 Optimizing MySQL In this tutorial we will show ... SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('Tricks'); +MATCH(title, body) AGAINST('Tricks') ORDER BY id; id title body 9 1001 MySQL Tricks How to use full-text search engine 10 Go MariaDB Tricks How to use full text search engine SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('full text search'); +MATCH(title, body) AGAINST('full text search') ORDER BY id; id title body -10 Go MariaDB Tricks How to use full text search engine 9 1001 MySQL Tricks How to use full-text search engine +10 Go MariaDB Tricks How to use full text search engine SELECT COUNT(*) FROM articles; COUNT(*) 5 @@ -183,7 +186,8 @@ UNINSTALL PLUGIN simple_parser; Warnings: Warning 1620 Plugin is busy and will be uninstalled on shutdown SELECT * FROM articles WHERE -MATCH(title, body) AGAINST('mysql'); +MATCH(title, body) AGAINST('mysql') +ORDER BY id; id title body 1 MySQL Tutorial DBMS stands for MySQL DataBase ... 2 How To Use MySQL Well After you went through a ... diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test b/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test index b22ac456668..7279925386b 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test @@ -6,6 +6,9 @@ # Install fts parser plugin INSTALL PLUGIN simple_parser SONAME 'mypluglib'; +# Flush the table mysql.plugin in case the server shutdown would time out. +FLUSH TABLES; + -- echo # Test Part 1: Grammar Test # Create a myisam table and alter it to innodb table CREATE TABLE articles ( @@ -52,7 +55,7 @@ INSERT INTO articles (title, body) VALUES # Simple term search SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('mysql'); + MATCH(title, body) AGAINST('mysql') ORDER BY id; # Test stopword and word len less than fts_min_token_size SELECT * FROM articles WHERE @@ -90,7 +93,7 @@ ALTER TABLE articles ADD FULLTEXT INDEX (title, body) WITH PARSER simple_parser; # Simple term search SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('mysql'); + MATCH(title, body) AGAINST('mysql') ORDER BY id; # Test stopword and word len less than fts_min_token_size SELECT * FROM articles WHERE @@ -105,10 +108,12 @@ SELECT * FROM articles WHERE # Test query expansion SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION); + MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION) + ORDER BY id; SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION); + MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION) + ORDER BY id; # No result here, we get '"mysql' 'database"' by simple parser SELECT * FROM articles WHERE @@ -150,13 +155,13 @@ INSERT INTO articles (title, body) VALUES --source include/restart_mysqld.inc SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('MySQL'); + MATCH(title, body) AGAINST('MySQL') ORDER BY id; SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('tutorial'); + MATCH(title, body) AGAINST('tutorial') ORDER BY id; SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('Tricks'); + MATCH(title, body) AGAINST('Tricks') ORDER BY id; SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('full text search'); + MATCH(title, body) AGAINST('full text search') ORDER BY id; SELECT COUNT(*) FROM articles; INSERT INTO articles (title, body) VALUES ('111', '1234 1234 1234'); @@ -193,7 +198,8 @@ UNINSTALL PLUGIN simple_parser; # Simple term search SELECT * FROM articles WHERE - MATCH(title, body) AGAINST('mysql'); + MATCH(title, body) AGAINST('mysql') + ORDER BY id; # Test stopword and word len less than fts_min_token_size SELECT * FROM articles WHERE -- cgit v1.2.1