From bad5fdec1843527fbbf87ef5e6f82519ffef3935 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Fri, 31 Oct 2014 12:48:17 +0100 Subject: [PATCH] Fix sporadic test failure in main.processlist The test runs a query in one thread, then in another queries the processlist and expects to find the first thread in the COM_SLEEP state. The problem is that the thread signals completion to the client before changing to COM_SLEEP state, so there is a window where the other thread can see the wrong state. A previous attempt to fix this was ineffective. It set a DEBUG_SYNC to handle proper waiting, but unfortunately that DEBUG_SYNC point ended up triggering already at the end of SET DEBUG_SYNC=xxx, so the wait was ineffective. Fix it properly now (hopefully) by ensuring that we wait for the DEBUG_SYNC point to trigger at the end of the SELECT SLEEP(), not just at the end of SET DEBUG_SYNC=xxx. --- mysql-test/r/processlist.result | 4 +++- mysql-test/t/processlist.test | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/processlist.result b/mysql-test/r/processlist.result index af97aba6634..0182245c278 100644 --- a/mysql-test/r/processlist.result +++ b/mysql-test/r/processlist.result @@ -7,7 +7,9 @@ SELECT ID, TIME,TIME_MS FROM INFORMATION_SCHEMA.PROCESSLIST WHERE CONCAT(":", ID SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed'; ID TIME TIME_MS TID 0 0.000 -SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done'; +SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done EXECUTE 2'; +SET DEBUG_SYNC= 'now WAIT_FOR query_done'; +SET DEBUG_SYNC= 'now SIGNAL nosignal'; select sleep(5); sleep(5) 0 diff --git a/mysql-test/t/processlist.test b/mysql-test/t/processlist.test index 12dd665b71b..9c555c0f9fb 100644 --- a/mysql-test/t/processlist.test +++ b/mysql-test/t/processlist.test @@ -28,7 +28,15 @@ connection default; # connection con1; -SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done'; +# Trigger a signal once the thread has gone from "Query" to "Sleep" command +# state. Note we need to execute this twice: Once at the end of SET DEBUG_SYNC, +# and once for the intended time, at the end of SELECT SLEEP(). +SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done EXECUTE 2'; +connection default; +# Wait for and clear the first signal set during SET DEBUG_SYNC. +SET DEBUG_SYNC= 'now WAIT_FOR query_done'; +SET DEBUG_SYNC= 'now SIGNAL nosignal'; +connection con1; select sleep(5); #run a query that will take some time connection default;