Bug #48724 | Deadlock between INSERT DELAYED and FLUSH TABLES | ||
---|---|---|---|
Submitted: | 12 Nov 2009 12:33 | Modified: | 7 Mar 2010 1:35 |
Reporter: | Jon Olav Hauglid | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S2 (Serious) |
Version: | 6.0.14-bzr, 6.0-codebase-bugfixing | OS: | Any |
Assigned to: | Jon Olav Hauglid | CPU Architecture: | Any |
Tags: | regression |
[12 Nov 2009 12:33]
Jon Olav Hauglid
[12 Nov 2009 12:39]
Jon Olav Hauglid
Also see bug#48725
[12 Nov 2009 13:33]
Valeriy Kravchuk
With recent mysql-6.0-codebase debug binaries I've got assertion failure on Mac OS X: Version: '6.0.14-alpha-debug-log' socket: '/Users/openxs/dbs/6.0-codebase/mysql-test/var/tmp/master.sock' port: 9306 Source distribution Assertion failed: (! thd->is_error()), function delayed_get_table, file sql_insert.cc, line 2047. ... So, we definitely have a problem here.
[12 Nov 2009 13:39]
Valeriy Kravchuk
Problem is NOT repeatable with recent 5.1.42 from bzr, so this is a regression bug.
[12 Nov 2009 14:08]
Jon Olav Hauglid
I reported the assertion as bug#48725. This deadlock happens less frequently.
[20 Nov 2009 10:31]
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/91051 3714 Jon Olav Hauglid 2009-11-20 Bug #48724 Deadlock between INSERT DELAYED and FLUSH TABLES The problem was that if the handler thread was killed at the wrong moment (using e.g. FLUSH TABLES), this would not be properly noticed by the INSERT DELAYED connection thread. It would be stuck waiting for the handler thread to lock its table, while the handler thread would be looping, trying to get the connection thread to notice the error. The root of the problem was that insert delayed had an extra variable "dead" used to indicate if the handler thread had been killed. This in addition to the usual "thd->killed". Most places both were set, but some only set "thd->killed". And Delayed_insert::get_local_table() only checked "dead" while waiting for the table to be locked. This patch removes the "dead" variable and replaces its usage with "thd->killed", thereby resolving the issue.
[17 Dec 2009 12:43]
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/94732 3041 Jon Olav Hauglid 2009-12-17 Bug #48724 Deadlock between INSERT DELAYED and FLUSH TABLES If the handler (or delayed insert) thread failed to lock a table due to being killed, the "dead" flag was used to notify the connection thread of this failure. However, with the changes introduced by Bug#45949, the handler thread will no longer try to lock the table if it was killed. This meant that the "dead" flag would not be set, and the connection thread would not notice that the handler thread had failed. This could happen with concurrent INSERT DELAYED and FLUSH TABLES. FLUSH TABLES would kill any active INSERT DELAYED that had opened any table(s) to be flushed. This could cause the INSERT DELAYED connection thread to be stuck waiting for the handler thread to lock its table, while the handler thread would be looping, trying to get the connection thread to notice the error. The root of the problem was that the handler thread had both the "dead" flag and "thd->killed" to indicate that it had been killed. Most places both were set, but some only set "thd->killed". And Delayed_insert::get_local_table() only checked "dead" while waiting for the table to be locked. This patch removes the "dead" variable and replaces its usage with "thd->killed", thereby resolving the issue.
[17 Dec 2009 14:39]
Jon Olav Hauglid
Pushed to mysql-next-4284 and merged to mysql-6.0-codebase-4284.
[16 Feb 2010 16:45]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:jon.hauglid@sun.com-20091217143610-t3t1lz1jcda1pney) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 16:55]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:jon.hauglid@sun.com-20091217124307-glwitkbztcmh8ajr) (pib:16)
[25 Feb 2010 21:02]
Paul DuBois
Noted in 6.0.14 changelog. Concurrent execution of INSERT DELAYED and FLUSH TABLES could lead to deadlock. Setting report to Need Merge pending push of Celosia to release tree.
[6 Mar 2010 11:08]
Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20100216221947-luyhph0txl2c5tc8) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 1:35]
Paul DuBois
Noted in 5.5.3 changelog.
[13 Apr 2010 4:55]
Paul DuBois
Correction: Not in any released version. No changelog entry needed.