• Jon Olav Hauglid's avatar
    Bug #52367 Deadlock involving SET GLOBAL EVENT_SCHEDULER = OFF · 7e6eddd3
    Jon Olav Hauglid authored
               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.
    7e6eddd3
event_scheduler.cc 21.4 KB