Skip to content

Commit

Permalink
MDEV-4393: show_explain.test times out randomly
Browse files Browse the repository at this point in the history
The problem was a race between the debug code in the server and the SHOW
EXPLAIN FOR in the test case.

The test case would wait for a query to reach the first point of interest
(inside dbug_serve_apcs()), then send it a SHOW EXPLAIN FOR, then wait for the
query to reach the next point of interest. However, the second wait was
insufficient. It was possible for the the second wait to complete immediately,
causing both the first and the second SHOW EXPLAIN FOR to hit the same
invocation of dbug_server_apcs(). Then a later invocation would miss its
intended SHOW EXPLAIN FOR and hang, and the test case would eventually time
out.

Fix is to make sure that the second wait can not trigger during the first
invocation of dbug_server_apcs(). We do this by clearing the thd_proc_info
(that the wait is looking for) before processing the SHOW EXPLAIN FOR; this
way the second wait can not start until the thd_proc_info from the first
invocation has been cleared.
  • Loading branch information
knielsen committed Dec 3, 2014
1 parent 2b5db1d commit d79cce8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,18 @@ static double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
void dbug_serve_apcs(THD *thd, int n_calls)
{
const char *save_proc_info= thd->proc_info;
/* This is so that mysqltest knows we're ready to serve requests: */
thd_proc_info(thd, "show_explain_trap");

/* Busy-wait for n_calls APC requests to arrive and be processed */
int n_apcs= thd->apc_target.n_calls_processed + n_calls;
while (thd->apc_target.n_calls_processed < n_apcs)
{
my_sleep(300);
/* This is so that mysqltest knows we're ready to serve requests: */
thd_proc_info(thd, "show_explain_trap");
my_sleep(30000);
thd_proc_info(thd, save_proc_info);
if (thd->check_killed())
break;
}
thd_proc_info(thd, save_proc_info);
}


Expand Down

0 comments on commit d79cce8

Please sign in to comment.