mirror of
https://github.com/MariaDB/server.git
synced 2025-04-21 22:55:35 +02:00
MDEV-24452 ALTER TABLE event take infinite time which for example breaks mysql_upgrade
The problem was that update_timing_fields_for_event() didn't release all MDL locks it took.
This commit is contained in:
parent
9930cb22c7
commit
6eb1eed53f
3 changed files with 52 additions and 0 deletions
14
mysql-test/main/alter_events.result
Normal file
14
mysql-test/main/alter_events.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET GLOBAL event_scheduler=1;
|
||||
CREATE TABLE t1 (a int primary key, b int) engine=innodb;
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
CREATE TABLE t2 (a int primary key) engine=innodb;
|
||||
CREATE EVENT e_t1 ON SCHEDULE EVERY 1 SECOND DO insert ignore into test.t2 select a from test.t1;
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
drop event e_t1;
|
||||
ALTER TABLE mysql.event DROP PRIMARY KEY, ADD PRIMARY KEY(db,name);
|
||||
drop table t1,t2;
|
||||
SET GLOBAL event_scheduler=default;
|
31
mysql-test/main/alter_events.test
Normal file
31
mysql-test/main/alter_events.test
Normal file
|
@ -0,0 +1,31 @@
|
|||
--source include/not_embedded.inc
|
||||
--source include/have_innodb.inc
|
||||
#--source include/have_metadata_lock_info.inc
|
||||
|
||||
#
|
||||
# Testing of problems with ALTER TABLE and events on the same table(s)
|
||||
#
|
||||
|
||||
#
|
||||
# MDEV-24452 ALTER TABLE event take infinite time which for example breaks
|
||||
# mysql_upgrade
|
||||
#
|
||||
|
||||
SET GLOBAL event_scheduler=1;
|
||||
|
||||
CREATE TABLE t1 (a int primary key, b int) engine=innodb;
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
CREATE TABLE t2 (a int primary key) engine=innodb;
|
||||
|
||||
CREATE EVENT e_t1 ON SCHEDULE EVERY 1 SECOND DO insert ignore into test.t2 select a from test.t1;
|
||||
|
||||
let $wait_condition=SELECT count(*) > 0 from t2;
|
||||
--source include/wait_condition.inc
|
||||
select * from t2;
|
||||
drop event e_t1;
|
||||
|
||||
# select * from information_schema.metadata_lock_info;
|
||||
ALTER TABLE mysql.event DROP PRIMARY KEY, ADD PRIMARY KEY(db,name);
|
||||
drop table t1,t2;
|
||||
|
||||
SET GLOBAL event_scheduler=default;
|
|
@ -1130,6 +1130,12 @@ update_timing_fields_for_event(THD *thd,
|
|||
|
||||
DBUG_ASSERT(thd->security_ctx->master_access & PRIV_IGNORE_READ_ONLY);
|
||||
|
||||
/*
|
||||
Take a savepoint to release only the lock on mysql.event
|
||||
table at the end but keep the global read lock and
|
||||
possible other locks taken by the caller.
|
||||
*/
|
||||
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
|
||||
if (open_event_table(thd, TL_WRITE, &table))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
|
@ -1162,6 +1168,7 @@ update_timing_fields_for_event(THD *thd,
|
|||
end:
|
||||
if (thd->commit_whole_transaction_and_close_tables())
|
||||
ret= 1;
|
||||
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
|
||||
|
||||
DBUG_RETURN(MY_TEST(ret));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue