MDEV-27523 main.delayed fails with wrong error code or timeout when executed 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)
This commit is contained in:
Sergei Golubchik 2023-10-15 23:50:30 +02:00
parent e9b38f684f
commit e46ae59265
4 changed files with 6 additions and 40 deletions

View File

@ -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;
@ -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,
@ -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;
@ -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;
@ -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);
@ -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);
@ -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);

View File

@ -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;
@ -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,
@ -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;
@ -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);
@ -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.
@ -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
@ -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);
@ -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);

View File

@ -919,7 +919,8 @@ public:
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)
{
@ -1028,7 +1029,7 @@ private:
*/
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);

View File

@ -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);
/*