mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#37481: status.test fails randomly
The problem was that the test was trying to obtain a lock on a table in one connection without ensuring that a insert which was executed in another connection had released the lock on the same table. The solution is to add a dummy select query after the insert to ensure that the table is unlocked and closed by the time it tries to lock it again. This is enough to prevent test failures described in the bug report. As an extra safety measure, concurrent inserts are disabled. Remove comments that calculated the Table_locks_immediate. This value is not tested anymore and it's calculation did not reflect the actual value. mysql-test/r/status.result: Update test case result. mysql-test/t/status.test: Issue a dummy select to ensure that tables are unlocked after a insert and disable concurrent inserts as a extra-safety.
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
set @old_concurrent_insert= @@global.concurrent_insert;
|
||||||
|
set @@global.concurrent_insert= 0;
|
||||||
flush status;
|
flush status;
|
||||||
show status like 'Table_lock%';
|
show status like 'Table_lock%';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
@ -7,22 +9,31 @@ select * from information_schema.session_status where variable_name like 'Table_
|
|||||||
VARIABLE_NAME VARIABLE_VALUE
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
TABLE_LOCKS_IMMEDIATE 2
|
TABLE_LOCKS_IMMEDIATE 2
|
||||||
TABLE_LOCKS_WAITED 0
|
TABLE_LOCKS_WAITED 0
|
||||||
SET SQL_LOG_BIN=0;
|
# Switched to connection: con1
|
||||||
|
set sql_log_bin=0;
|
||||||
set @old_general_log = @@global.general_log;
|
set @old_general_log = @@global.general_log;
|
||||||
set global general_log = 'OFF';
|
set global general_log = 'OFF';
|
||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
create table t1(n int) engine=myisam;
|
create table t1(n int) engine=myisam;
|
||||||
insert into t1 values(1);
|
insert into t1 values(1);
|
||||||
|
select 1;
|
||||||
|
1
|
||||||
|
1
|
||||||
|
# Switched to connection: con2
|
||||||
lock tables t1 read;
|
lock tables t1 read;
|
||||||
unlock tables;
|
unlock tables;
|
||||||
lock tables t1 read;
|
lock tables t1 read;
|
||||||
|
# Switched to connection: con1
|
||||||
update t1 set n = 3;
|
update t1 set n = 3;
|
||||||
|
# Switched to connection: con2
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
# Switched to connection: con1
|
||||||
show status like 'Table_locks_waited';
|
show status like 'Table_locks_waited';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Table_locks_waited 1
|
Table_locks_waited 1
|
||||||
drop table t1;
|
drop table t1;
|
||||||
set global general_log = @old_general_log;
|
set global general_log = @old_general_log;
|
||||||
|
# Switched to connection: default
|
||||||
select 1;
|
select 1;
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -198,3 +209,4 @@ ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table '
|
|||||||
drop database db37908;
|
drop database db37908;
|
||||||
drop procedure proc37908;
|
drop procedure proc37908;
|
||||||
drop function func37908;
|
drop function func37908;
|
||||||
|
set @@global.concurrent_insert= @old_concurrent_insert;
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
# embedded server causes different stat
|
# embedded server causes different stat
|
||||||
-- source include/not_embedded.inc
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
|
# Disable concurrent inserts to avoid sporadic test failures as it might
|
||||||
|
# affect the the value of variables used throughout the test case.
|
||||||
|
set @old_concurrent_insert= @@global.concurrent_insert;
|
||||||
|
set @@global.concurrent_insert= 0;
|
||||||
|
|
||||||
# PS causes different statistics
|
# PS causes different statistics
|
||||||
--disable_ps_protocol
|
--disable_ps_protocol
|
||||||
|
|
||||||
@ -12,54 +17,45 @@ connect (con2,localhost,root,,);
|
|||||||
|
|
||||||
flush status;
|
flush status;
|
||||||
|
|
||||||
# Logging to the general query log table (--log-output=table --log) increments
|
|
||||||
# Table_locks_immediate with each query, so here Immediate becomes 1
|
|
||||||
show status like 'Table_lock%';
|
show status like 'Table_lock%';
|
||||||
# ++Immediate = 2
|
|
||||||
select * from information_schema.session_status where variable_name like 'Table_lock%';
|
select * from information_schema.session_status where variable_name like 'Table_lock%';
|
||||||
|
|
||||||
connection con1;
|
connection con1;
|
||||||
# ++Immediate = 3
|
--echo # Switched to connection: con1
|
||||||
SET SQL_LOG_BIN=0;
|
set sql_log_bin=0;
|
||||||
set @old_general_log = @@global.general_log;
|
set @old_general_log = @@global.general_log;
|
||||||
set global general_log = 'OFF';
|
set global general_log = 'OFF';
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
# ++Immediate = 4
|
|
||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
# ++Immediate = 5
|
|
||||||
create table t1(n int) engine=myisam;
|
create table t1(n int) engine=myisam;
|
||||||
# Immediate + 2 = 7
|
|
||||||
insert into t1 values(1);
|
insert into t1 values(1);
|
||||||
|
# Execute dummy select in order to ensure that tables used in the
|
||||||
|
# previous statement are unlocked and closed.
|
||||||
|
select 1;
|
||||||
|
|
||||||
connection con2;
|
connection con2;
|
||||||
# Immediate + 2 = 9
|
--echo # Switched to connection: con2
|
||||||
lock tables t1 read;
|
lock tables t1 read;
|
||||||
# ++Immediate = 10
|
|
||||||
unlock tables;
|
unlock tables;
|
||||||
# Immediate + 2 = 12
|
|
||||||
lock tables t1 read;
|
lock tables t1 read;
|
||||||
|
|
||||||
connection con1;
|
connection con1;
|
||||||
# ++Immediate = 13
|
--echo # Switched to connection: con1
|
||||||
let $ID= `select connection_id()`;
|
let $ID= `select connection_id()`;
|
||||||
# ++Immediate = 14 (Not +2, because this increments Table_locks_waited)
|
--send update t1 set n = 3
|
||||||
--send
|
|
||||||
update t1 set n = 3;
|
|
||||||
|
|
||||||
connection con2;
|
connection con2;
|
||||||
|
--echo # Switched to connection: con2
|
||||||
# wait for the other query to start executing
|
# wait for the other query to start executing
|
||||||
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Locked";
|
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Locked";
|
||||||
# Immediate = 14 + $wait_condition_reps ($wait_timeout is 0, so no extra select
|
|
||||||
# is done inside wait_condition.inc)
|
|
||||||
--source include/wait_condition.inc
|
--source include/wait_condition.inc
|
||||||
# ++Immediate = 15 + $wait_condition_reps
|
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
|
||||||
connection con1;
|
connection con1;
|
||||||
|
--echo # Switched to connection: con1
|
||||||
reap;
|
reap;
|
||||||
# ++Immediate = 16 + $wait_condition_reps
|
|
||||||
show status like 'Table_locks_waited';
|
show status like 'Table_locks_waited';
|
||||||
drop table t1;
|
drop table t1;
|
||||||
set global general_log = @old_general_log;
|
set global general_log = @old_general_log;
|
||||||
@ -67,6 +63,7 @@ set global general_log = @old_general_log;
|
|||||||
disconnect con2;
|
disconnect con2;
|
||||||
disconnect con1;
|
disconnect con1;
|
||||||
connection default;
|
connection default;
|
||||||
|
--echo # Switched to connection: default
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
@ -295,3 +292,7 @@ drop database db37908;
|
|||||||
drop procedure proc37908;
|
drop procedure proc37908;
|
||||||
drop function func37908;
|
drop function func37908;
|
||||||
# End of 5.1 tests
|
# End of 5.1 tests
|
||||||
|
|
||||||
|
# Restore global concurrent_insert value. Keep in the end of the test file.
|
||||||
|
--connection default
|
||||||
|
set @@global.concurrent_insert= @old_concurrent_insert;
|
||||||
|
Reference in New Issue
Block a user