Bug #30887 Server crashes on SET GLOBAL query_cache_size=0
Submitted: 7 Sep 2007 10:29 Modified: 25 Jan 20:32
Reporter: Kristofer Pettersson
Status: Closed
Category:Server: Query Cache Severity:S2 (Serious)
Version:5.1 BK OS:Any
Assigned to: Kristofer Pettersson Target Version:5.1
Triage: D4 (Minor)

[7 Sep 2007 10:29] Kristofer Pettersson
Description:
Reseting the query cache by issuing a SET GLOBAL query_cache_size=0 will cause the server
to crash if a the server concurrently is saving a new result set to the query cache. The
reason for this is that the fast invalidation isn't waiting on the result writers to
release the block level locks in the query cache.

How to repeat:
* INSERT a set of fairly large blobs into a table as (nr,blobl)
* Activate query cache and start SELECTing.
* Concurrently change query cache size between 0 and 100000 until the server crash.

Suggested fix:
Count result writers and don't free the cache unless there are no active result writers.
[7 Dec 2007 11:28] 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/39505

ChangeSet@1.2649, 2007-12-07 11:31:55+01:00, thek@adventure.(none) +3 -0
  Bug#30887 Server crashes on SET GLOBAL query_cache_size=0
  
  Reseting the query cache by issuing a SET GLOBAL query_cache_size=0 caused the server
  to crash if a the server concurrently was saving a new result set to the query cache.
The
  reason for this was that the invalidation wasn't waiting on the result writers to
  release the block level locks on the query cache.
[3 Jan 15:32] 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/40509

ChangeSet@1.2649, 2008-01-03 15:36:48+01:00, thek@adventure.(none) +3 -0
  Bug#30887 Server crashes on SET GLOBAL query_cache_size=0
  
  Reseting the query cache by issuing a SET GLOBAL query_cache_size=0 caused the server
  to crash if a the server concurrently was saving a new result set to the query cache.
The
  reason for this was that the invalidation wasn't waiting on the result writers to
  release the block level locks on the query cache.
[25 Jan 13:35] Bugs System
Pushed into 5.1.24-rc
[25 Jan 13:38] Bugs System
Pushed into 6.0.5-alpha
[25 Jan 20:32] Paul DuBois
Noted in 5.1.24, 6.0.5 changelogs.
[8 Feb 7:41] Shane Bester
FYI, the stack trace in a possible crash looks like this:

mysqld-debug.exe!Query_cache_query::result
mysqld-debug.exe!query_cache_insert
mysqld-debug.exe!net_real_write
mysqld-debug.exe!net_flush
mysqld-debug.exe!net_send_eof
mysqld-debug.exe!net_end_statement
mysqld-debug.exe!dispatch_command
mysqld-debug.exe!do_command
mysqld-debug.exe!handle_one_connection
mysqld-debug.exe!pthread_start
mysqld-debug.exe!_callthreadstart
mysqld-debug.exe!_threadstart
kernel32.dll!BaseThreadStart()  + 0x3a bytes
[6 Mar 10:38] Jon Stephens
Also documented for 5.1.23-ndb-6.2.14.
[30 Mar 21:43] Jon Stephens
Also documented for 5.1.23-ndb-6.3.11.