Commit 7e6eddd3 authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

Bug #52367 Deadlock involving SET GLOBAL EVENT_SCHEDULER = OFF

           during rqg_mdl_deadlock test

The problem was that if two connection threads simultaneously tries
to execute "SET GLOBAL EVENT_SCHEDULER = OFF", one of them could
hang waiting for the scheduler to stop.

The first connection thread would kill the event scheduler thread
and then start waiting for it to exit. The second connection thread
would then find the event scheduler thread in the process of exiting
and also wait for it to exit. However, since the event scheduler 
thread used signal to wake only one waiting thread, the other connection
thread would be left waiting.

This bug was a regression introduced by the fix for Bug#51160.
Before #51160 it was not possible for two connection threads to 
try to stop the event scheduler thread simultaneously.

This patch fixes the problem my making sure the event scheduler
thread uses broadcast to notify all waiters that it is exiting.

No test case added as this would require adding debug sync points
to parts of the code where sync points are currently not used.
The patch has been tested with the non-deterministic test case
from the bug description as well as using the RQG.
parent ef50dd1b
/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc /* Copyright (C) 2004, 2010 Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "events.h" #include "events.h"
...@@ -497,8 +497,8 @@ Event_scheduler::run(THD *thd) ...@@ -497,8 +497,8 @@ Event_scheduler::run(THD *thd)
deinit_event_thread(thd); deinit_event_thread(thd);
scheduler_thd= NULL; scheduler_thd= NULL;
state= INITIALIZED; state= INITIALIZED;
DBUG_PRINT("info", ("Signalling back to the stopper COND_state")); DBUG_PRINT("info", ("Broadcasting COND_state back to the stoppers"));
mysql_cond_signal(&COND_state); mysql_cond_broadcast(&COND_state);
UNLOCK_DATA(); UNLOCK_DATA();
DBUG_RETURN(res); DBUG_RETURN(res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment