Bug #56096 | STOP SLAVE hangs if executed in parallel with user sleep | ||
---|---|---|---|
Submitted: | 18 Aug 2010 19:24 | Modified: | 20 Nov 2010 17:18 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.5.5-m3, 5.6.1-m4 | OS: | Any |
Assigned to: | Davi Arnaut | CPU Architecture: | Any |
Tags: | regression |
[18 Aug 2010 19:24]
Elena Stepanova
[29 Sep 2010 0:10]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/119325 3206 Davi Arnaut 2010-09-28 Bug#56096: STOP SLAVE hangs if executed in parallel with user sleep The problem is that although the slave thread is awaken (via a spurious event) when a slave stop is issued, the slave thread is not explicitly killed. This can lead to a infinite loop if the event which the slave thread was waiting for is not properly restarted (and comes to a end eventually). Since the SLEEP function sleeps on a timed event in order to be killable and to perform periodic checks until the requested time has elapsed, the spurious wake up was causing the requested sleep time to be reset every two seconds. The solution is to calculate the requested absolute time only once and to ensure that the thread only sleeps until this time is elapsed. In case of a spurious wake up, the sleep is restarted using the previously calculated absolute time. This restores the behavior present in previous releases. If a slave thread is executing a SLEEP function, a STOP SLAVE statement will wait until the time requested in the sleep function has elapsed. @ mysql-test/extra/rpl_tests/rpl_start_stop_slave.test Add test case result for Bug#56096. @ mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result Add test case for Bug#56096. @ sql/item_func.cc Reorganize interruptible_wait so that the absolute time can be preserved across calls to the function. This allow the sleep to be properly restarted in the presence of spurious wake ups generated by a STOP SLAVE.
[14 Oct 2010 1:54]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/120740 3244 Davi Arnaut 2010-10-13 Bug#56096: STOP SLAVE hangs if executed in parallel with user sleep The root of the problem is that to interrupt a slave SQL thread wait, the STOP SLAVE implementation uses thd->awake(THD::NOT_KILLED). This appears as a spurious wakeup (e.g. from a sleep on a condition variable) to the code that the slave SQL thread is executing at the time of the STOP. If the code is not written to be spurious-wakeup safe, unexpected behavior can occur. For the reported case, this problem led to an infinite loop around the interruptible_wait() function in item_func.cc (SLEEP() function implementation). The loop was not being properly restarted and, consequently, would not come to an end. Since the SLEEP function sleeps on a timed event in order to be killable and to perform periodic checks until the requested time has elapsed, the spurious wake up was causing the requested sleep time to be reset every two seconds. The solution is to calculate the requested absolute time only once and to ensure that the thread only sleeps until this time is elapsed. In case of a spurious wake up, the sleep is restarted using the previously calculated absolute time. This restores the behavior present in previous releases. If a slave thread is executing a SLEEP function, a STOP SLAVE statement will wait until the time requested in the sleep function has elapsed. @ mysql-test/extra/rpl_tests/rpl_start_stop_slave.test Add test case for Bug#56096. @ mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result Add test case result for Bug#56096. @ sql/item_func.cc Reorganize interruptible_wait into a class so that the absolute time can be preserved across calls to the wait function. This allows the sleep to be properly restarted in the presence of spurious wake ups, including those generated by a STOP SLAVE.
[14 Oct 2010 2:29]
Davi Arnaut
Queued to mysql-5.5-bugteam.
[13 Nov 2010 16:15]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:33]
Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[20 Nov 2010 17:18]
Paul DuBois
Noted in 5.5.8 changelog. If a STOP SLAVE statement was issued while the slave SQL thread was executing a statement that invoked the SLEEP() function, both statements hung.
[16 Dec 2010 22:35]
Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)