File: change_user_deadlock.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (78 lines) | stat: -rw-r--r-- 2,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Run it only if --big-test option is specified
-- source include/big_test.inc

--echo #
--echo # Bug#110494 "Deadlock between FLUSH STATUS, COM_CHANGE_USER
--echo # and SELECT FROM I_S.PROCESSLIST".
--echo #

--echo # The original problem reported was that concurrent execution of
--echo # COM_STATISTICS, COM_CHANGE_USER commands and SHOW FULL PROCESSLIST
--echo # statements sometimes led to deadlock. This test uses FLUSH STATUS
--echo # statement instead of the first command and SELECT ... FROM
--echo # I_S.PROCESSLIST instead of the latter. They acquire the same
--echo # locks and were affected by the same problem.
--echo # Doing 3000 concurrent runs of each statement was enough to reproduce
--echo # the deadlock with 80% probability on my machine.
--echo # Hence, the test doesn't reproduce the issue consistently. It is observed
--echo # that the test fails when run with mtr option --repeat=10 or more.
--echo # Also, it is hard to write a MTR test using DEBUG_SYNC, because
--echo # MTR doesn't allow us to run --change_user in background.

--delimiter |

CREATE PROCEDURE p_flush_status()
BEGIN
  DECLARE x INT DEFAULT 3000;
  WHILE x DO
    SET x = x-1;
    FLUSH STATUS;
  END WHILE;
END |

CREATE PROCEDURE p_processlist()
BEGIN
  DECLARE x INT DEFAULT 3000;
  WHILE x DO
    SET x = x-1;
    SELECT COUNT(*) INTO @a FROM information_schema.processlist;
  END WHILE;
END |

--delimiter ;

--enable_connect_log
--connect (con1, localhost, root,,)
--echo # Send:
--send CALL p_flush_status()

--echo # Send:
--connect (con2, localhost, root,,)
--send CALL p_processlist()

--connection default

--echo # Execute COM_CHANGE_USER command 3000 times.
let $i = 3000;
while ($i)
{
  dec $i;
--change_user
}

--connection con1
--echo # Reap p_flush_status().
--reap
--disconnect con1
--source include/wait_until_disconnected.inc

--connection con2
--echo # Reap p_processlist().
--reap
--disconnect con2
--source include/wait_until_disconnected.inc

--connection default
--disable_connect_log
DROP PROCEDURE p_flush_status;
DROP PROCEDURE p_processlist;