Skip to content

Commit

Permalink
MDEV-27523 main.delayed fails with wrong error code or timeout when e…
Browse files Browse the repository at this point in the history
…xecuted after main.deadlock_ftwrl

don't forget to reset mdl_context.m_deadlock_overweight when
taking the THD out of the cache - the history of previous connections
should not affect the weight in deadlock victim selection

(small cleanup of the test to help the correct merge)
  • Loading branch information
vuvova committed Oct 17, 2023
1 parent e9b38f6 commit e46ae59
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
11 changes: 1 addition & 10 deletions mysql-test/main/delayed.result
@@ -1,4 +1,3 @@
drop table if exists t1;
create table t1 (a char(10), tmsp timestamp);
insert into t1 set a = 1;
insert delayed into t1 set a = 2;
Expand Down Expand Up @@ -259,7 +258,6 @@ INSERT DELAYED INTO t1 SET b= b();
ERROR 42000: FUNCTION test.b does not exist
DROP TABLE t1;
End of 5.0 tests
DROP TABLE IF EXISTS t1,t2;
SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
CREATE TABLE `t1` (
`id` int(11) PRIMARY KEY auto_increment,
Expand Down Expand Up @@ -293,7 +291,6 @@ set global low_priority_updates = 1;
select @@global.low_priority_updates;
@@global.low_priority_updates
1
drop table if exists t1;
create table t1 (a int, b int);
insert into t1 values (1,1);
lock table t1 read;
Expand Down Expand Up @@ -322,7 +319,6 @@ set global low_priority_updates = @old_delayed_updates;
#
# Bug #47682 strange behaviour of INSERT DELAYED
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (f1 integer);
CREATE TABLE t2 (f1 integer);
FLUSH TABLES WITH READ LOCK;
Expand All @@ -335,8 +331,6 @@ End of 5.1 tests
#
# Bug #47274 assert in open_table on CREATE TABLE <already existing>
#
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
# The following CREATE TABLEs before gave an assert.
INSERT DELAYED t1 VALUES (4);
Expand All @@ -352,14 +346,12 @@ CREATE TABLE t2 (f1 INTEGER);
INSERT DELAYED t1 VALUES (7);
CREATE TABLE t1 LIKE t2;
ERROR 42S01: Table 't1' already exists
DROP TABLE t2;
DROP TABLE t1;
DROP TABLE t2, t1;
#
# Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
#
# This test is not supposed to work under --ps-protocol since
# INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT);
Expand Down Expand Up @@ -450,7 +442,6 @@ DROP TABLE t1, t2, t3;
#
connect con1,localhost,root,,;
connection default;
drop table if exists t1, t2, tm;
create table t1(a int);
create table t2(a int);
create table tm(a int) engine=merge union=(t1, t2);
Expand Down
29 changes: 1 addition & 28 deletions mysql-test/main/delayed.test
Expand Up @@ -21,9 +21,6 @@ select @@global.storage_engine in
("memory","myisam","archive","blackhole") as `TRUE`;
enable_query_log;

--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a char(10), tmsp timestamp);
insert into t1 set a = 1;
insert delayed into t1 set a = 2;
Expand Down Expand Up @@ -276,9 +273,6 @@ DROP TABLE t1;
#
# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
CREATE TABLE `t1` (
`id` int(11) PRIMARY KEY auto_increment,
Expand Down Expand Up @@ -315,9 +309,6 @@ set @old_delayed_updates = @@global.low_priority_updates;
set global low_priority_updates = 1;
select @@global.low_priority_updates;

--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int, b int);
insert into t1 values (1,1);
lock table t1 read;
Expand Down Expand Up @@ -351,10 +342,6 @@ set global low_priority_updates = @old_delayed_updates;
--echo # Bug #47682 strange behaviour of INSERT DELAYED
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

CREATE TABLE t1 (f1 integer);
CREATE TABLE t2 (f1 integer);

Expand All @@ -378,11 +365,6 @@ DROP TABLE t1, t2;
--echo # Bug #47274 assert in open_table on CREATE TABLE <already existing>
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings

CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));

--echo # The following CREATE TABLEs before gave an assert.
Expand All @@ -404,9 +386,7 @@ INSERT DELAYED t1 VALUES (7);
--error ER_TABLE_EXISTS_ERROR
CREATE TABLE t1 LIKE t2;

DROP TABLE t2;
DROP TABLE t1;

DROP TABLE t2, t1;

--echo #
--echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
Expand All @@ -417,10 +397,6 @@ DROP TABLE t1;
--disable_ps_protocol
--disable_view_protocol

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT);
Expand Down Expand Up @@ -573,9 +549,6 @@ DROP TABLE t1, t2, t3;
--disable_view_protocol
connect (con1,localhost,root,,);
connection default;
--disable_warnings
drop table if exists t1, t2, tm;
--enable_warnings
create table t1(a int);
create table t2(a int);
create table tm(a int) engine=merge union=(t1, t2);
Expand Down
5 changes: 3 additions & 2 deletions sql/mdl.h
Expand Up @@ -919,7 +919,8 @@ class MDL_context
already has received some signal or closed
signal slot.
*/
void init(MDL_context_owner *arg) { m_owner= arg; }
void init(MDL_context_owner *arg) { m_owner= arg; reset(); }
void reset() { m_deadlock_overweight= 0; }

void set_needs_thr_lock_abort(bool needs_thr_lock_abort)
{
Expand Down Expand Up @@ -1028,7 +1029,7 @@ class MDL_context
*/
MDL_wait_for_subgraph *m_waiting_for;
LF_PINS *m_pins;
uint m_deadlock_overweight= 0;
uint m_deadlock_overweight;
private:
MDL_ticket *find_ticket(MDL_request *mdl_req,
enum_mdl_duration *duration);
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.cc
Expand Up @@ -1209,6 +1209,7 @@ const Type_handler *THD::type_handler_for_datetime() const
void THD::init()
{
DBUG_ENTER("thd::init");
mdl_context.reset();
mysql_mutex_lock(&LOCK_global_system_variables);
plugin_thdvar_init(this);
/*
Expand Down

0 comments on commit e46ae59

Please sign in to comment.