Bug #47378 assertion in query cache when running event scheduler
Submitted: 16 Sep 2009 15:12 Modified: 26 Sep 2012 17:19
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Query Cache Severity:S1 (Critical)
Version:5.1.38-debug OS:Any
Assigned to: CPU Architecture:Any

[16 Sep 2009 15:12] Shane Bester
Description:
Assertion failed: 0, file .\sql_cache.cc, line 977
mysqld-debug.exe!_NMSG_WRITE()[crt0msg.c:198]
mysqld-debug.exe!abort()[abort.c:68]
mysqld-debug.exe!_wassert()[assert.c:212]
mysqld-debug.exe!query_cache_end_of_result()[sql_cache.cc:977]
mysqld-debug.exe!sp_instr_stmt::execute()[sp_head.cc:2855]
mysqld-debug.exe!sp_head::execute()[sp_head.cc:1252]
mysqld-debug.exe!sp_head::execute_procedure()[sp_head.cc:1982]
mysqld-debug.exe!Event_job_data::execute()[event_data_objects.cc:1462]
mysqld-debug.exe!Event_worker_thread::run()[event_scheduler.cc:307]
mysqld-debug.exe!event_worker_thread()[event_scheduler.cc:266]
mysqld-debug.exe!pthread_start()[my_winthread.c:85]
mysqld-debug.exe!_callthreadstart()[thread.c:295]
mysqld-debug.exe!_threadstart()[thread.c:277]
kernel32.dll!BaseThreadStart()
ariables.
 invalid and cause the dump to abort...
001A971498=select * from t1

if (header->result() == 0)
{
     DBUG_PRINT("error", ("End of data with no result blocks; "
           "Query '%s' removed from cache.", header->query()));
   /*
     Extra safety: empty result should not happen in the normal call
     to this function. In the release version that query should be ignored
     and removed from QC.
   */
   DBUG_ASSERT(0);  <---------- here
   query_cache.free_query(query_block);
   query_cache.unlock();
   DBUG_VOID_RETURN;
}

How to repeat:
enable query cache, event scheduler, create some events that populate/use the querycache, restart server with them enabled.  crash happened shortly after startup.  exact testcase later..
[16 Sep 2009 15:34] MySQL Verification Team
testcase:

start debug server with --query-cache-size=10M --query-cache-type=1 --event-scheduler=1 and create and event:

truncate mysql.event;
drop table if exists t1;
create table t1(a int,key(a))engine=innodb;
insert into t1 values (1),(2),(3);
drop event if exists myevent5;
delimiter $
create event myevent5 on schedule every 1 second enable do
begin
declare i int default '0';
declare continue handler for sqlexception begin end;
repeat
select * from t1;
set i:=i+1;
until i>1000 end repeat;
end $
delimiter ;
[26 Sep 2012 17:19] Jon Stephens
Fixed in 5.6.8, trunk. Closed.
[28 Sep 2016 14:13] MySQL Verification Team
http://bugs.mysql.com/bug.php?id=83188
[5 Dec 2017 2:55] Roel Van de Paar
https://bugs.mysql.com/bug.php?id=88751
[5 Dec 2017 6:55] MySQL Verification Team
Bug #88751 marked as duplicate of this one