Bug #37774 main.events_bugs fails sporadically
Submitted: 1 Jul 2008 15:42 Modified: 29 Jun 2009 0:59
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:6.0-BK OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: disabled, pushbuild, sporadic, test failure

[1 Jul 2008 15:42] Alexander Nozdrin
Description:
Symptom 1:
----------------------------------------------------------
mysqltest: At line 168: query 'select release_lock('ee_16407_2')' failed: 2013: Lost connection to MySQL server during query

The result from queries just before the failure was:
< snip >
set sql_mode=""|
"This will insert rows but they will be truncated"
create event ee_16407_4 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60) /*ee_16407_4*/;
select release_lock('ee_16407_2');
insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956');
end|
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema	event_name	sql_mode
events_test	ee_16407_2	STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test	ee_16407_3	STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test	ee_16407_4	
select /*2*/ user, host, db, info from information_schema.processlist where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') order by info;
user	host	db	info
event_scheduler	localhost	NULL	NULL
root	localhost	events_test	select get_lock('ee_16407_2', 60)
root	localhost	events_test	select get_lock('ee_16407_2', 60)
root	localhost	events_test	select get_lock('ee_16407_2', 60)
select release_lock('ee_16407_2');
----------------------------------------------------------

Symptom 2:
----------------------------------------------------------
mysqltest: In included file "./include/wait_condition.inc": At line 53: Error running query 'select count(*) = 2 from information_schema.processlist
where info = 'select get_lock(\'ee_16407_5\', 60)'': 2013 Lost connection to MySQL server during query

The result from queries just before the failure was:
< snip >
set sql_mode='ansi';
select get_lock('ee_16407_5', 60);
get_lock('ee_16407_5', 60)
1
set global event_scheduler= on;
set sql_mode='traditional';
create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
create event ee_16407_5 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60) /*ee_16407_5*/;
select release_lock('ee_16407_5');
call events_test.ee_16407_5_pendant();
end|
create event ee_16407_6 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60) /*ee_16407_6*/;
select release_lock('ee_16407_5');
call events_test.ee_16407_6_pendant();
end|
----------------------------------------------------------

Symptom 3:
----------------------------------------------------------
mysqltest: At line 373: query 'select release_lock('ee_22830')' failed: 2013: Lost connection to MySQL server during query

The result from queries just before the failure was:
< snip >
"All events should be blocked in get_lock()"
select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
event_name	event_definition	interval_value	interval_field
e22830_1	begin
call p22830_wait();
alter event e22830_1 on schedule every (select 8 from dual) hour;
end	1	HOUR
e22830_2	begin
call p22830_wait();
alter event e22830_2 on schedule every (select 8 from t1) hour;
end	1	HOUR
e22830_3	begin
call p22830_wait();
alter event e22830_3 on schedule every f22830() hour;
end	1	HOUR
e22830_4	begin
call p22830_wait();
alter event e22830_4 on schedule every (select f22830() from dual) hour;
end	1	HOUR
select release_lock('ee_22830');
----------------------------------------------------------

How to repeat:
https://intranet.mysql.com/secure/pushbuild/xref.pl?testname=main.events_bugs
[1 Jul 2008 15:43] Alexander Nozdrin
See also Bug#32782.
[22 Apr 2009 8:56] 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/72643

3224 Alexey Botchkov	2009-04-22
      Bug#37774      main.events_bugs fails sporadically
          get_lock() function can crash the system when used inside the event handler.
          the interruptible_wait() function used in the implementation calls
          thd->vio_is_connected() in some circumstances and this method leads to
          crash when the thread doesn't have an real connection (thd->net.vio is NULL).
      
          Fixed by checking that thd->net.vio isn't NULL.
      
      per-file messages:
        mysql-test/r/events_bugs.result
      Bug#37774      main.events_bugs fails sporadically
           test result fixed
           some results changed since test was disabled
      
        mysql-test/t/disabled.def
      
      Bug#37774      main.events_bugs fails sporadically
          test reenabled
      
        sql/item_func.cc
      Bug#37774      main.events_bugs fails sporadically
          thd->net.vio is verified before thd->vio_is_connected() call
[13 May 2009 10:09] 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/73916

3270 Alexey Botchkov	2009-05-13
      Bug#37774      main.events_bugs fails sporadically
          get_lock() function can crash the system when used inside the event handler.
          the interruptible_wait() function used in the implementation calls
          thd->vio_is_connected() in some circumstances and this method leads to
          crash when the thread doesn't have an real connection (thd->net.vio is NULL).
      
          Fixed by checking that thd->net.vio isn't NULL.
            
      per-file messages:
        mysql-test/r/events_bugs.result
      Bug#37774      main.events_bugs fails sporadically
           test result fixed
           some results changed since test was disabled
      
        mysql-test/t/disabled.def
      
      Bug#37774      main.events_bugs fails sporadically
          test reenabled
      
        sql/item_func.cc
      Bug#37774      main.events_bugs fails sporadically
          thd->vio_ok() is verified before thd->vio_is_connected() call
[17 Jun 2009 19:27] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version source revid:holyfoot@mysql.com-20090513084227-k0rt5cvr0wndmx0b) (merge vers: 6.0.12-alpha) (pib:11)
[29 Jun 2009 0:59] Paul DuBois
Noted in 5.4.4 changelog.

Use of GET_LOCK() within an Event Manager event could cause a server
crash.