Skip to content

Commit

Permalink
MDEV-32897 main suite test case prints extra row for metadata_lock_in…
Browse files Browse the repository at this point in the history
…fo query

- Added the parameter stats_persistent=0 for InnoDB engine.
- Before printing metadata_lock_info query, make sure that
InnoDB does complete purging.

Reviewed by: Marko Mäkelä
  • Loading branch information
Thirunarayanan committed Nov 29, 2023
1 parent 47fc64c commit e996f77
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 19 deletions.
8 changes: 6 additions & 2 deletions mysql-test/main/backup_interaction.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
#
# Check backup and FTWRL
#
Expand Down Expand Up @@ -95,7 +97,7 @@ drop table t1;
#
# BACKUP STAGE performs implicit commits
#
create table t1(a int) engine=InnoDB;
create table t1(a int) stats_persistent=0, engine=InnoDB;
begin;
insert into t1 values(1);
select lock_mode from information_schema.metadata_lock_info;
Expand Down Expand Up @@ -197,8 +199,9 @@ drop table t1;
# CHECK: RO transaction under BACKUP STAGE is a potential deadlock
# OTOH we most probably allow them under FTWRL as well
#
CREATE TABLE t1 (col1 INT) ENGINE = InnoDB;
CREATE TABLE t1 (col1 INT)stats_persistent=0, ENGINE = InnoDB;
insert into t1 values (1);
InnoDB 0 transactions not purged
backup stage start;
backup stage block_commit;
begin;
Expand Down Expand Up @@ -526,3 +529,4 @@ FLUSH TABLE t1 WITH READ LOCK;
ERROR HY000: Can't execute the command as you have a BACKUP STAGE active
BACKUP STAGE END;
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
9 changes: 7 additions & 2 deletions mysql-test/main/backup_interaction.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
--source include/have_innodb.inc
--source include/have_metadata_lock_info.inc

SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;

--echo #
--echo # Check backup and FTWRL
--echo #
Expand Down Expand Up @@ -120,7 +123,7 @@ drop table t1;
--echo # BACKUP STAGE performs implicit commits
--echo #
--disable_view_protocol
create table t1(a int) engine=InnoDB;
create table t1(a int) stats_persistent=0, engine=InnoDB;
begin;
insert into t1 values(1);
select lock_mode from information_schema.metadata_lock_info;
Expand Down Expand Up @@ -221,8 +224,9 @@ drop table t1;
--echo # OTOH we most probably allow them under FTWRL as well
--echo #
--disable_view_protocol
CREATE TABLE t1 (col1 INT) ENGINE = InnoDB;
CREATE TABLE t1 (col1 INT)stats_persistent=0, ENGINE = InnoDB;
insert into t1 values (1);
--source ../suite/innodb/include/wait_all_purged.inc
backup stage start;
backup stage block_commit;
begin;
Expand Down Expand Up @@ -521,3 +525,4 @@ FLUSH TABLE t1 FOR EXPORT;
FLUSH TABLE t1 WITH READ LOCK;
BACKUP STAGE END;
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
11 changes: 9 additions & 2 deletions mysql-test/main/backup_lock.result
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#
# Testing which locks we get from all stages
#
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
InnoDB 0 transactions not purged
BACKUP STAGE START;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
Expand Down Expand Up @@ -29,7 +32,8 @@ connection default;
#
# testing if BACKUP STAGE FLUSH causes deadlocks with ALTER TABLE
#
create table t1 (a int) engine=innodb;
create table t1 (a int) stats_persistent= 0, engine=innodb;
InnoDB 0 transactions not purged
start transaction;
insert into t1 values (1);
connection con1;
Expand Down Expand Up @@ -95,7 +99,8 @@ drop table t1;
#
# testing if BACKUP STAGE FLUSH causes deadlocks with DROP TABLE
#
create table t1 (a int) engine=innodb;
create table t1 (a int)stats_persistent=0, engine=innodb;
InnoDB 0 transactions not purged
start transaction;
insert into t1 values (1);
connection con1;
Expand All @@ -122,6 +127,7 @@ connection default;
# Check if backup stage block_dll + concurrent drop table blocks select
#
create table t1 (a int) engine=innodb;
InnoDB 0 transactions not purged
backup stage start;
backup stage block_ddl;
connection con1;
Expand Down Expand Up @@ -217,3 +223,4 @@ DROP TABLE t_permanent_myisam, t_permanent_innodb;
DROP TABLE t_con1_innodb, t_con1_myisam;
disconnect con1;
set global lock_wait_timeout=default;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
12 changes: 9 additions & 3 deletions mysql-test/main/backup_lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
--echo # Testing which locks we get from all stages
--echo #

SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
--source ../suite/innodb/include/wait_all_purged.inc
BACKUP STAGE START;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
BACKUP STAGE FLUSH;
Expand All @@ -36,8 +39,8 @@ connection default;
--echo # testing if BACKUP STAGE FLUSH causes deadlocks with ALTER TABLE
--echo #

create table t1 (a int) engine=innodb;

create table t1 (a int) stats_persistent= 0, engine=innodb;
--source ../suite/innodb/include/wait_all_purged.inc
start transaction;
# Acquires MDL lock
insert into t1 values (1);
Expand Down Expand Up @@ -123,7 +126,8 @@ drop table t1;
--echo # testing if BACKUP STAGE FLUSH causes deadlocks with DROP TABLE
--echo #

create table t1 (a int) engine=innodb;
create table t1 (a int)stats_persistent=0, engine=innodb;
--source ../suite/innodb/include/wait_all_purged.inc
start transaction;
# Acquires MDL lock
insert into t1 values (1);
Expand Down Expand Up @@ -159,6 +163,7 @@ connection default;
--echo #

create table t1 (a int) engine=innodb;
--source ../suite/innodb/include/wait_all_purged.inc
backup stage start;
backup stage block_ddl;
connection con1;
Expand Down Expand Up @@ -284,3 +289,4 @@ DROP TABLE t_permanent_myisam, t_permanent_innodb;
DROP TABLE t_con1_innodb, t_con1_myisam;
--disconnect con1
set global lock_wait_timeout=default;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
7 changes: 6 additions & 1 deletion mysql-test/main/backup_locks.result
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#
# Test lock taken
#
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
InnoDB 0 transactions not purged
BACKUP LOCK test.t1;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
Expand All @@ -23,7 +26,7 @@ BACKUP UNLOCK;
#
connect con1,localhost,root,,;
connection default;
create table t1 (a int) engine=innodb;
create table t1 (a int) stats_persistent=0,engine=innodb;
insert into t1 values (1);
backup lock t1;
select * from t1;
Expand All @@ -32,6 +35,7 @@ a
connection con1;
drop table t1;
connection default;
InnoDB 0 transactions not purged
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
MDL_SHARED_HIGH_PRIO Table metadata lock test t1
Expand Down Expand Up @@ -93,6 +97,7 @@ BACKUP LOCK t1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
INSERT INTO t1 VALUES(0);
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
# restart
DROP TABLE t1;
DROP TABLE t2;
Expand Down
10 changes: 6 additions & 4 deletions mysql-test/main/backup_locks.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
--echo #
--echo # Test lock taken
--echo #

SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
--source ../suite/innodb/include/wait_all_purged.inc
BACKUP LOCK test.t1;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
BACKUP UNLOCK;
Expand All @@ -29,7 +31,7 @@ BACKUP UNLOCK;
connect (con1,localhost,root,,);

connection default;
create table t1 (a int) engine=innodb;
create table t1 (a int) stats_persistent=0,engine=innodb;
insert into t1 values (1);
backup lock t1;
select * from t1;
Expand All @@ -40,6 +42,7 @@ let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table metadata lock";
--source include/wait_condition.inc
--source ../suite/innodb/include/wait_all_purged.inc
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
--error ER_LOCK_DEADLOCK
select * from t1;
Expand Down Expand Up @@ -107,6 +110,7 @@ LOCK TABLES t2 AS a2 WRITE;
BACKUP LOCK t1;
UNLOCK TABLES;
INSERT INTO t1 VALUES(0);
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
--source include/restart_mysqld.inc
DROP TABLE t1;
DROP TABLE t2;
Expand Down Expand Up @@ -187,7 +191,6 @@ LOCK TABLES t3 AS a2 WRITE, t3 AS a1 READ LOCAL;
DROP TABLE t3;
BACKUP UNLOCK;
DROP TABLE t3;

--echo #
--echo # MDEV-28367: BACKUP LOCKS on table to be accessible to those
--echo # with database LOCK TABLES privileges
Expand Down Expand Up @@ -260,7 +263,6 @@ disconnect con1;

drop database db1;
drop user user1@localhost;

--echo #
--echo # End of MariaDB 10.4 tests
--echo #
4 changes: 4 additions & 0 deletions mysql-test/main/backup_stages.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
#-----------------------------------------------------------------------
# Multi-threaded tests
#-----------------------------------------------------------------------
Expand All @@ -17,6 +19,7 @@ FROM information_schema.processlist WHERE id = @con1_id;
ID USER COMMAND STATE INFO STAGE MAX_STAGE INFO_BINARY
<con1_id> root Query Waiting for backup lock BACKUP STAGE START 0 0 BACKUP STAGE START
BACKUP STAGE END;
InnoDB 0 transactions not purged
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
MDL_BACKUP_START Backup lock
Expand Down Expand Up @@ -333,3 +336,4 @@ disconnect con11;
disconnect con12;
disconnect backup;
connection default;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
4 changes: 4 additions & 0 deletions mysql-test/main/backup_stages.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc

SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
let $old_lock_wait_timeout = `SELECT @@global.lock_wait_timeout`;

--echo #-----------------------------------------------------------------------
Expand Down Expand Up @@ -50,6 +52,7 @@ FROM information_schema.processlist WHERE id = @con1_id;
# con1 uses @@global.lock_wait_timeout

BACKUP STAGE END;
--source ../suite/innodb/include/wait_all_purged.inc
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;

--connection con1
Expand Down Expand Up @@ -383,3 +386,4 @@ SET GLOBAL lock_wait_timeout = $old_lock_wait_timeout;

--connection default
--source include/wait_until_count_sessions.inc
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
4 changes: 4 additions & 0 deletions mysql-test/main/create_or_replace.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
drop table if exists t1,t2,t3;
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES(1),(2),(3);
#
Expand Down Expand Up @@ -260,6 +262,7 @@ Note 1051 Unknown table 'mysqltest2.t2'
create table test.t1 (i int) engine=myisam;
create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
InnoDB 0 transactions not purged
select * from information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock
Expand Down Expand Up @@ -576,6 +579,7 @@ CREATE TABLE tm (a INT) ENGINE=MERGE UNION(t);
CREATE OR REPLACE TABLE t LIKE tm;
ERROR HY000: Table 'tm' is specified twice, both as a target for 'CREATE' and as a separate source for data
DROP TABLE IF EXISTS tm, t;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
#
# End of 10.3 tests
#
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/main/create_or_replace.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
drop table if exists t1,t2,t3;
--enable_warnings

SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
#
# Create help table
#
Expand Down Expand Up @@ -216,6 +218,7 @@ drop table if exists test.t1,mysqltest2.t2;
create table test.t1 (i int) engine=myisam;
create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--source ../suite/innodb/include/wait_all_purged.inc
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info;
Expand Down Expand Up @@ -523,6 +526,7 @@ CREATE OR REPLACE TABLE t LIKE tm;
# Cleanup
DROP TABLE IF EXISTS tm, t;

SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
--echo #
--echo # End of 10.3 tests
--echo #
Expand Down
8 changes: 7 additions & 1 deletion mysql-test/main/mdl.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
# mdl_ticket->m_type == MDL_SHARED_READ'
# failed in MDL_context::upgrade_shared_lock
#
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
CREATE TABLE t1(a INT) ENGINE=InnoDB;
CREATE TABLE t3(a INT) ENGINE=myisam;
InnoDB 0 transactions not purged
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
Expand Down Expand Up @@ -56,14 +59,15 @@ DROP TABLE t1,t3;
#
# Check MDL locks taken for different kind of tables by open
#
CREATE TABLE t1(a INT) ENGINE=InnoDB;
CREATE TABLE t1(a INT) stats_persistent=0, ENGINE=InnoDB;
CREATE TABLE t3(a INT) ENGINE=myisam;
connect locker,localhost,root,,;
connection default;
FLUSH TABLES WITH READ LOCK;
connection locker;
insert into t1 values (1);
connection default;
InnoDB 0 transactions not purged
connection default;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
Expand All @@ -77,6 +81,7 @@ FLUSH TABLES WITH READ LOCK;
connection locker;
insert into t3 values (2);
connection default;
InnoDB 0 transactions not purged
connection default;
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
Expand Down Expand Up @@ -129,6 +134,7 @@ disconnect foo;
connection default;
set autocommit=default;
drop table t2;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
#
# End of 10.4 tests
#
Loading

0 comments on commit e996f77

Please sign in to comment.