Skip to content

Commit b771483

Browse files
Matthias LeichMatthias Leich
Matthias Leich
authored and
Matthias Leich
committed
Last slice of fix for Bug#42003 tests missing the disconnect of connections <> default
+ Fix for Bug#43114 wait_until_count_sessions too restrictive, random PB failures + Removal of a lot of other weaknesses found + modifications according to review
1 parent 209cc33 commit b771483

39 files changed

+1354
-904
lines changed

mysql-test/include/wait_until_count_sessions.inc

+23-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22
#
33
# SUMMARY
44
#
5-
# Waits until the passed number ($count_sessions) of concurrent sessions was
6-
# observed via
5+
# Waits until the passed number ($count_sessions) of concurrent sessions or
6+
# a smaller number was observed via
77
# SHOW STATUS LIKE 'Threads_connected'
88
# or the operation times out.
9-
# Note: Starting with 5.1 we could also use
10-
# SELECT COUNT(*) FROM information_schema.processlist
11-
# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
12-
# runs in all versions 5.0+
9+
# Note:
10+
# 1. We wait for $current_sessions <= $count_sessions because in the use case
11+
# with count_sessions.inc before and wait_until_count_sessions.inc after
12+
# the core of the test it could happen that the disconnects of sessions
13+
# belonging to the preceeding test are not finished.
14+
# sessions at test begin($count_sessions) = m + n
15+
# sessions of the previous test which will be soon disconnected = n (n >= 0)
16+
# sessions at test end ($current sessions, assuming the test disconnects
17+
# all additional sessions) = m
18+
# 2. Starting with 5.1 we could also use
19+
# SELECT COUNT(*) FROM information_schema.processlist
20+
# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
21+
# runs in all versions 5.0+
1322
#
1423
#
1524
# USAGE
@@ -19,7 +28,7 @@
1928
#
2029
# OR typical example of a test which uses more than one session
2130
# Such a test could harm successing tests if there is no server shutdown
22-
# and start between.cw
31+
# and start between.
2332
#
2433
# If the testing box is slow than the disconnect of sessions belonging to
2534
# the current test might happen when the successing test gets executed.
@@ -79,7 +88,11 @@
7988
# backup.test, grant3.test
8089
#
8190
#
82-
# Created: 2009-01-14 mleich
91+
# Created:
92+
# 2009-01-14 mleich
93+
# Modified:
94+
# 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive,
95+
# random PB failures
8396
#
8497

8598
let $wait_counter= 100;
@@ -93,7 +106,7 @@ let $wait_timeout= 0;
93106
while ($wait_counter)
94107
{
95108
let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
96-
let $success= `SELECT $current_sessions = $count_sessions`;
109+
let $success= `SELECT $current_sessions <= $count_sessions`;
97110
if ($success)
98111
{
99112
let $wait_counter= 0;
@@ -107,7 +120,7 @@ while ($wait_counter)
107120
if (!$success)
108121
{
109122
--echo # Timeout in wait_until_count_sessions.inc
110-
--echo # Number of sessions expected: $count_sessions found: $current_sessions
123+
--echo # Number of sessions expected: < $count_sessions found: $current_sessions
111124
SHOW PROCESSLIST;
112125
}
113126

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
drop table if exists t1;
2-
create table t1 (a int) engine=innodb;
3-
start transaction with consistent snapshot;
4-
insert into t1 values(1);
5-
select * from t1;
1+
DROP TABLE IF EXISTS t1;
2+
# Establish connection con1 (user=root)
3+
# Establish connection con2 (user=root)
4+
# Switch to connection con1
5+
CREATE TABLE t1 (a INT) ENGINE=innodb;
6+
START TRANSACTION WITH CONSISTENT SNAPSHOT;
7+
# Switch to connection con2
8+
INSERT INTO t1 VALUES(1);
9+
# Switch to connection con1
10+
SELECT * FROM t1;
611
a
7-
commit;
8-
delete from t1;
9-
start transaction;
10-
insert into t1 values(1);
11-
select * from t1;
12+
COMMIT;
13+
DELETE FROM t1;
14+
START TRANSACTION;
15+
# Switch to connection con2
16+
INSERT INTO t1 VALUES(1);
17+
# Switch to connection con1
18+
SELECT * FROM t1;
1219
a
1320
1
14-
commit;
15-
drop table t1;
21+
COMMIT;
22+
# Switch to connection default + close connections con1 and con2
23+
DROP TABLE t1;

mysql-test/r/dirty_close.result

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
drop table if exists t1;
2-
create table t1 (n int);
3-
insert into t1 values (1),(2),(3);
4-
select * from t1;
1+
DROP TABLE IF EXISTS t1;
2+
CREATE TABLE t1 (n INT);
3+
INSERT INTO t1 VALUES (1),(2),(3);
4+
SELECT * FROM t1;
55
n
66
1
77
2
88
3
9-
drop table t1;
9+
DROP TABLE t1;
+46-28
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
1-
drop table if exists t1;
2-
create table t1 (a int) engine=innodb;
3-
begin;
4-
insert into t1 values(1);
5-
flush tables with read lock;
6-
select * from t1;
1+
# Establish connection con1 (user=root)
2+
# Establish connection con2 (user=root)
3+
# Establish connection con3 (user=root)
4+
# Switch to connection con1
5+
DROP TABLE IF EXISTS t1;
6+
CREATE TABLE t1 (a INT) ENGINE=innodb;
7+
BEGIN;
8+
INSERT INTO t1 VALUES(1);
9+
# Switch to connection con2
10+
FLUSH TABLES WITH READ LOCK;
11+
SELECT * FROM t1;
712
a
8-
commit;
9-
select * from t1;
13+
# Switch to connection con1
14+
COMMIT;
15+
# Switch to connection con2
16+
SELECT * FROM t1;
1017
a
11-
unlock tables;
12-
begin;
13-
select * from t1 for update;
18+
UNLOCK TABLES;
19+
# Switch to connection con1
20+
# Switch to connection con1
21+
BEGIN;
22+
SELECT * FROM t1 FOR UPDATE;
1423
a
1524
1
16-
begin;
17-
select * from t1 for update;
18-
flush tables with read lock;
19-
commit;
25+
# Switch to connection con2
26+
BEGIN;
27+
SELECT * FROM t1 FOR UPDATE;
28+
# Switch to connection con3
29+
FLUSH TABLES WITH READ LOCK;
30+
# Switch to connection con1
31+
COMMIT;
32+
# Switch to connection con2
2033
a
2134
1
22-
unlock tables;
23-
commit;
24-
begin;
25-
insert into t1 values(10);
26-
flush tables with read lock;
27-
commit;
28-
unlock tables;
29-
flush tables with read lock;
30-
unlock tables;
31-
begin;
32-
select * from t1;
35+
# Switch to connection con3
36+
UNLOCK TABLES;
37+
# Switch to connection con2
38+
COMMIT;
39+
# Switch to connection con1
40+
BEGIN;
41+
INSERT INTO t1 VALUES(10);
42+
FLUSH TABLES WITH READ LOCK;
43+
COMMIT;
44+
UNLOCK TABLES;
45+
# Switch to connection con2
46+
FLUSH TABLES WITH READ LOCK;
47+
UNLOCK TABLES;
48+
BEGIN;
49+
SELECT * FROM t1;
3350
a
3451
1
3552
10
36-
show create database test;
53+
SHOW CREATE DATABASE test;
3754
Database Create Database
3855
test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
39-
drop table t1;
56+
DROP TABLE t1;
57+
# Switch to connection default and close connections con1, con2, con3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
create table t1 (a int) engine=innodb;
2-
reset master;
3-
set autocommit=0;
4-
insert t1 values (1);
5-
flush tables with read lock;
6-
show master status;
1+
# Establish connection con1 (user=root)
2+
# Establish connection con2 (user=root)
3+
# Switch to connection con1
4+
CREATE TABLE t1 (a INT) ENGINE=innodb;
5+
RESET MASTER;
6+
SET AUTOCOMMIT=0;
7+
INSERT t1 VALUES (1);
8+
# Switch to connection con2
9+
FLUSH TABLES WITH READ LOCK;
10+
SHOW MASTER STATUS;
711
File Position Binlog_Do_DB Binlog_Ignore_DB
812
master-bin.000001 98
9-
commit;
10-
show master status;
13+
# Switch to connection con1
14+
COMMIT;
15+
# Switch to connection con2
16+
SHOW MASTER STATUS;
1117
File Position Binlog_Do_DB Binlog_Ignore_DB
1218
master-bin.000001 98
13-
unlock tables;
14-
drop table t1;
15-
set autocommit=1;
19+
UNLOCK TABLES;
20+
# Switch to connection con1
21+
DROP TABLE t1;
22+
SET AUTOCOMMIT=1;
23+
# Switch to connection default and close connections con1 and con2
+10-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
drop table if exists t1;
2-
create table t1 (kill_id int);
3-
insert into t1 values(connection_id());
4-
flush tables with read lock;
5-
select ((@id := kill_id) - kill_id) from t1;
1+
SET @old_concurrent_insert= @@global.concurrent_insert;
2+
SET @@global.concurrent_insert= 0;
3+
DROP TABLE IF EXISTS t1;
4+
CREATE TABLE t1 (kill_id INT);
5+
INSERT INTO t1 VALUES(connection_id());
6+
FLUSH TABLES WITH READ LOCK;
7+
SELECT ((@id := kill_id) - kill_id) FROM t1;
68
((@id := kill_id) - kill_id)
79
0
8-
kill connection @id;
9-
drop table t1;
10+
KILL CONNECTION @id;
11+
DROP TABLE t1;
12+
SET @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/r/lock_multi.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock
5151
UNLOCK TABLES;
5252
DROP DATABASE mysqltest_1;
5353
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
54-
use mysql;
54+
USE mysql;
5555
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
5656
FLUSH TABLES;
57-
use mysql;
57+
USE mysql;
5858
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
5959
OPTIMIZE TABLES columns_priv, db, host, user;
6060
Table Op Msg_type Msg_text
@@ -65,7 +65,7 @@ mysql.user optimize status OK
6565
UNLOCK TABLES;
6666
Select_priv
6767
N
68-
use test;
68+
USE test;
6969
use test;
7070
CREATE TABLE t1 (c1 int);
7171
LOCK TABLE t1 WRITE;
@@ -93,7 +93,7 @@ create table t1 (a int);
9393
connection: locker
9494
lock tables t1 read;
9595
connection: writer
96-
create table t2 like t1;;
96+
create table t2 like t1;
9797
connection: default
9898
kill query
9999
ERROR 70100: Query execution was interrupted

mysql-test/r/mysqlbinlog.result

+8-8
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,17 @@ DELIMITER ;
349349
ROLLBACK /* added by mysqlbinlog */;
350350
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
351351
CREATE TABLE t1 (c1 CHAR(10));
352-
flush logs;
352+
FLUSH LOGS;
353353
INSERT INTO t1 VALUES ('0123456789');
354-
flush logs;
354+
FLUSH LOGS;
355355
DROP TABLE t1;
356356
# Query thread_id=REMOVED exec_time=REMOVED error_code=REMOVED
357-
flush logs;
358-
create table t1(a int);
359-
insert into t1 values(connection_id());
360-
flush logs;
361-
drop table t1;
357+
FLUSH LOGS;
358+
CREATE TABLE t1(a INT);
359+
INSERT INTO t1 VALUES(connection_id());
360+
FLUSH LOGS;
361+
DROP TABLE t1;
362362
1
363-
drop table t1;
363+
DROP TABLE t1;
364364
shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql
365365
End of 5.0 tests

mysql-test/r/read_only.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Note 1051 Unknown table 'ttt'
4747
drop table t1,t2;
4848
drop user test@localhost;
4949
#
50-
# Bug #27440 read_only allows create and drop database
50+
# Bug#27440 read_only allows create and drop database
5151
#
5252
drop database if exists mysqltest_db1;
5353
drop database if exists mysqltest_db2;

mysql-test/r/show_check.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql
507507
drop table mysqltest.t1;
508508
drop database mysqltest;
509509
set names binary;
510-
delete from mysql.user
510+
delete from mysql.user
511511
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
512-
delete from mysql.db
512+
delete from mysql.db
513513
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
514514
flush privileges;
515515
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY;
@@ -916,7 +916,7 @@ def TRIGGERS DEFINER Definer 252 589815 14 N 17 0 33
916916
Trigger Event Table Statement Timing Created sql_mode Definer
917917
t1_bi INSERT t1 SET @a = 1 BEFORE NULL root@localhost
918918
----------------------------------------------------------------
919-
SELECT
919+
SELECT
920920
TRIGGER_CATALOG,
921921
TRIGGER_SCHEMA,
922922
TRIGGER_NAME,

mysql-test/r/skip_name_resolve.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
55
GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
66
REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255';
77
DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
8-
select user();
9-
user()
8+
SELECT USER();
9+
USER()
1010
#
11-
show processlist;
11+
SHOW PROCESSLIST;
1212
Id User Host db Command Time State Info
1313
<id> root <host> test <command> <time> <state> <info>
1414
<id> root <host> test <command> <time> <state> <info>

0 commit comments

Comments
 (0)