|
| 1 | +--source include/not_embedded.inc |
| 2 | +--source include/have_pool_of_threads.inc |
| 3 | + |
| 4 | +--echo # MDEV-33070 Thread pool starvation at oversubscribe threshold |
| 5 | + |
| 6 | +# The server is started with a single thread group, a dedicated listener, |
| 7 | +# one worker thread, and thread_pool_oversubscribe=1. |
| 8 | +# |
| 9 | +# c1 and c2 run long queries and occupy the one worker plus the one allowed |
| 10 | +# oversubscribe slot. c3 submits a trivial INSERT which the listener can only |
| 11 | +# enqueue, because it is sent only after both c1 and c2 are confirmed running. |
| 12 | +# |
| 13 | +# Before the fix, after c1 was killed the worker stayed at the oversubscribe |
| 14 | +# threshold and went to sleep instead of dequeuing c3. Because |
| 15 | +# thread_pool_dedicated_listener=ON, only the worker can drain the queue, so if |
| 16 | +# c3 is still pending while c1 and c2 run and completes only after c1 is |
| 17 | +# killed, then the worker resumed dequeuing. |
| 18 | + |
| 19 | +CREATE TABLE t1 (a INT); |
| 20 | + |
| 21 | +--connect (c1, localhost, root,,) |
| 22 | +--connect (c2, localhost, root,,) |
| 23 | +--connect (c3, localhost, root,,) |
| 24 | +--connect (extra_con, 127.0.0.1, root,,test,$MASTER_EXTRA_PORT,) |
| 25 | + |
| 26 | +--connection c1 |
| 27 | +--let $c1_id= `SELECT CONNECTION_ID()` |
| 28 | +--send SELECT SLEEP(1000) |
| 29 | + |
| 30 | +--connection extra_con |
| 31 | +let $wait_condition= |
| 32 | + SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST |
| 33 | + WHERE STATE='User sleep' AND ID=$c1_id; |
| 34 | +--source include/wait_condition.inc |
| 35 | + |
| 36 | +--connection c2 |
| 37 | +--let $c2_id= `SELECT CONNECTION_ID()` |
| 38 | +--send SELECT SLEEP(1000) |
| 39 | + |
| 40 | +--connection extra_con |
| 41 | +let $wait_condition= |
| 42 | + SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST |
| 43 | + WHERE STATE='User sleep' AND ID=$c2_id; |
| 44 | +--source include/wait_condition.inc |
| 45 | + |
| 46 | +--connection c3 |
| 47 | +--send INSERT INTO t1 VALUES (1) |
| 48 | + |
| 49 | +--connection extra_con |
| 50 | +--replace_result $c1_id c1_id |
| 51 | +eval KILL QUERY $c1_id; |
| 52 | + |
| 53 | +let $wait_timeout= 10; |
| 54 | +let $wait_condition= |
| 55 | + SELECT COUNT(*) = 1 FROM t1; |
| 56 | +--source include/wait_condition.inc |
| 57 | +SELECT COUNT(*) = 1 FROM t1; |
| 58 | + |
| 59 | +--connection c1 |
| 60 | +--error 0,ER_QUERY_INTERRUPTED,ER_STATEMENT_TIMEOUT |
| 61 | +--reap |
| 62 | +--disconnect c1 |
| 63 | + |
| 64 | +--connection extra_con |
| 65 | +--replace_result $c2_id c2_id |
| 66 | +eval KILL QUERY $c2_id; |
| 67 | + |
| 68 | +--connection c2 |
| 69 | +--error 0,ER_QUERY_INTERRUPTED |
| 70 | +--reap |
| 71 | +--disconnect c2 |
| 72 | + |
| 73 | +--connection c3 |
| 74 | +--reap |
| 75 | +--disconnect c3 |
| 76 | + |
| 77 | +--connection extra_con |
| 78 | +SELECT COUNT(*) = 1 FROM t1; |
| 79 | +--disconnect extra_con |
| 80 | + |
| 81 | +--connection default |
| 82 | +DROP TABLE t1; |
| 83 | +--echo # End of MDEV-33070 tests |
0 commit comments