Bug #23655 deadlock in query cache ndb_cache tests with --debug
Submitted: 26 Oct 2006 4:55 Modified: 24 Jan 2007 20:52
Reporter: Stewart Smith Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.1.13 OS:
Assigned to: Stewart Smith CPU Architecture:Any

[26 Oct 2006 4:55] Stewart Smith
Deadlock when running ndb_cache tests with --debug. Query cache locks on trying to acquire lock.

Looks like incorrect unlocking order in sql_cache.cc

How to repeat:
run mysql-test-run.pl --do-test=ndb_cache

Suggested fix:
===== sql/sql_cache.cc 1.93 vs edited =====
--- 1.93/sql/sql_cache.cc       2006-10-26 14:49:53 +10:00
+++ edited/sql/sql_cache.cc     2006-10-24 19:54:50 +10:00
@@ -751,11 +751,10 @@
     header->result()->type= Query_cache_block::RESULT;
     thd->net.query_cache_query= 0;
-    DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
-    STRUCT_UNLOCK(&query_cache.structure_guard_mutex);

+    DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
+    STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
[26 Oct 2006 7:38] Tomash Brechko
This bug was introduced with the fix of bug#21051.  The bug happens only in debug mode when check_integrity() tries to acquire the lock on a query block that is still locked.  There is only one such bogus place, and suggested fix is correct.

Thanks for fixing this, Stewart!
[26 Oct 2006 11:13] Stewart Smith
merging into -ndb trees
[26 Oct 2006 11: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:


ChangeSet@1.2310, 2006-10-26 21:37:23+10:00, stewart@willster.(none) +1 -0
  BUG#23655 deadlock in query cache ndb_cache tests with --debug
  Deadlock when running ndb_cache tests with --debug. Query cache locks on trying
  to acquire lock.
[8 Nov 2006 4:11] Stewart Smith
Pushed to 5.1-ndb
[29 Dec 2006 1:06] Stewart Smith
probably nothing to document, only affected debug. only 5.1 affected.
[24 Jan 2007 20:52] Paul DuBois
No changelog entry needed.