Bug #43587 Putting event_scheduler=1 in init SQL file crashes mysqld
Submitted: 12 Mar 2009 11:44 Modified: 7 Aug 2009 20:24
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.1.32 OS:Any (Linux)
Assigned to: Davi Arnaut CPU Architecture:Any

[12 Mar 2009 11:44] Geert Vanderkelen
Description:
Putting SET GLOBAL event_scheduler = 1 in the SQL init file crashes the mysqld

090312 12:35:43 mysqld_safe mysqld restarted
090312 12:35:43  InnoDB: Started; log sequence number 0 8302404
/usr/sbin/mysqld(my_print_stacktrace+0x21)[0x848a381]
/usr/sbin/mysqld(handle_segfault+0x37f)[0x81e24ff]
[0x51a420]
/lib/libpthread.so.0(pthread_mutex_lock+0x20)[0x2ab3a0]
/usr/sbin/mysqld(_ZN15Event_scheduler9lock_dataEPKcj+0x12)[0x8334172]
/usr/sbin/mysqld(_ZN15Event_scheduler5startEv+0x23)[0x8334883]
/usr/sbin/mysqld(_ZN6Events28switch_event_scheduler_stateENS_24enum_opt_event_schedulerE+0xad)[0x833a1ed]
/usr/sbin/mysqld(_ZN23sys_var_event_scheduler6updateEP3THDP7set_var+0x14)[0x81fa3c4]
/usr/sbin/mysqld(_ZN7set_var6updateEP3THD+0x63)[0x81f9a73]
/usr/sbin/mysqld(_Z17sql_set_variablesP3THDP4ListI12set_var_baseE+0x7c)[0x8204f9c]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x3d85)[0x81f3885]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x1ee)[0x81f725e]
/usr/sbin/mysqld(handle_bootstrap+0x3b6)[0x81f8e56]
/lib/libpthread.so.0[0x2a945b]
/lib/libc.so.6(clone+0x5e)[0x229e5e]
090312 12:35:43 - mysqld got signal 11 ;

How to repeat:
Nothing more than this in my.cnf:

[mysqld]
init_file = /etc/mysql/init.sql

init.sql contains:

SET GLOBAL event_scheduler = 1;

Suggested fix:
Workaround or best practice: don't do it, set it in my.cnf.
Shouldn't crash though.
[12 Mar 2009 11:45] Geert Vanderkelen
Verified using 5.1.32-community on CentOS 5.2 (MySQL-server-community-5.1.32-0.rhel5)
[11 Jun 2009 8:11] 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/76097

2936 Christoffer Hall	2009-06-11
      Bug#43587: Putting event_scheduler=1 in init SQL file crashes mysqld
      
      If the event scheduler is enabled in an init sql file mysqld crashes.
      
      When the init sql file containing "SET GLOBAL event_scheduler = 1" gets
      executed before events are configured in my.cnf mysqld crashes because
      switching scheduler state assumes events are initialized.
      
      The solution is to initialize the event system on demand, unless events are
      disabled on the commandline.
[22 Jun 2009 9:57] 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/76799

2968 Christoffer Hall	2009-06-22
      BUG#43587  Putting event_scheduler=1 in init SQL file crashes mysqld
                  
      Second patch to fix the problem. Trying to dynamically init events doesn't work as early as when init_file= is run. So issuing a warining that events cannot be set so early is issued and default values (or values set in my.cnf) will be loaded later.
[29 Jun 2009 9:08] 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/77432

2982 Christoffer Hall	2009-06-29
      BUG#43587  Putting event_scheduler=1 in init SQL file crashes mysqld
                              
      Second patch to fix the problem. Trying to dynamically init events doesn't work
      as early as when init_file= is run. The problem is that some code depends on
      thread_count going to zero and if events are inited, the event thread will be
      around. So initialization freezes. Issuing a warning that events cannot be
      set so early is issued and default values (or values set in my.cnf) will be
      loaded later seems like the most tractable solution.
[24 Jul 2009 16:21] 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/79263

3041 Konstantin Osipov	2009-07-24
      Code review for Bug#43587 Putting event_scheduler=1 in init SQL file crashes 
      mysqld
[24 Jul 2009 18:27] 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/79272

3042 Davi Arnaut	2009-07-24 [merge]
      Bug#43587: Putting event_scheduler=1 in init SQL file crashes
      mysqld
      
      The problem was that enabling the event scheduler inside a init
      file caused the server to crash upon start-up. The crash occurred
      because the event scheduler wasn't being initialized before the
      commands in the init-file are processed.
      
      The solution is to initialize the event scheduler before the init
      file is read. The patch also disables the event scheduler during
      bootstrap and makes the bootstrap operation robust in the
      presence of background threads.
     @ mysql-test/std_data/init_file.dat
        Add test case for Bug#43587
     @ sql/event_scheduler.cc
        Signal that the thread_count has been decremented.
     @ sql/events.cc
        Disable the event scheduler during bootstrap.
     @ sql/mysql_priv.h
        Export variable.
     @ sql/mysqld.cc
        Initialize the event scheduler before commands are executed.
     @ sql/sql_parse.cc
        Signal that the bootstrap thread is done.
[24 Jul 2009 18:46] 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/79273

3042 Davi Arnaut	2009-07-24 [merge]
      Bug#43587: Putting event_scheduler=1 in init SQL file crashes
      mysqld
      
      The problem was that enabling the event scheduler inside a init
      file caused the server to crash upon start-up. The crash occurred
      because the event scheduler wasn't being initialized before the
      commands in the init-file are processed.
      
      The solution is to initialize the event scheduler before the init
      file is read. The patch also disables the event scheduler during
      bootstrap and makes the bootstrap operation robust in the
      presence of background threads.
     @ mysql-test/std_data/init_file.dat
        Add test case for Bug#43587
     @ sql/event_scheduler.cc
        Signal that the thread_count has been decremented.
     @ sql/events.cc
        Disable the event scheduler during bootstrap.
     @ sql/mysql_priv.h
        Export variable.
     @ sql/mysqld.cc
        Initialize the event scheduler before commands are executed.
     @ sql/sql_parse.cc
        Signal that the bootstrap thread is done.
[24 Jul 2009 19:12] Davi Arnaut
Queued to 5.1-bugteam
[27 Jul 2009 19:04] 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/79365

3041 Davi Arnaut	2009-07-27
      Post-merge fix for Bug#43587: Handle failures to execute a statement
      during bootstrap on a embedded server.
     @ libmysqld/lib_sql.cc
        Handle a failure during bootstrap.
[4 Aug 2009 19:50] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090804194615-h40sa098mx4z49qg) (version source revid:davi.arnaut@sun.com-20090727191546-d0glf93zrlefm0mq) (merge vers: 5.4.4-alpha) (pib:11)
[4 Aug 2009 20:45] Bugs System
Pushed into 5.1.38 (revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (version source revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (merge vers: 5.1.38) (pib:11)
[7 Aug 2009 20:24] Paul DuBois
Noted in 5.1.38, 5.4.4 changelogs.

Enabling the event scheduler from within the file specified by
--init-file caused a server crash.
[12 Aug 2009 22:40] Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 1:57] Paul DuBois
Ignore previous comment about 5.4.2.
[1 Oct 2009 5:58] Bugs System
Pushed into 5.1.39-ndb-6.3.28 (revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (version source revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (merge vers: 5.1.39-ndb-6.3.28) (pib:11)
[1 Oct 2009 7:25] Bugs System
Pushed into 5.1.39-ndb-7.0.9 (revid:jonas@mysql.com-20091001072547-kv17uu06hfjhgjay) (version source revid:jonas@mysql.com-20091001071652-irejtnumzbpsbgk2) (merge vers: 5.1.39-ndb-7.0.9) (pib:11)
[1 Oct 2009 13:25] Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (version source revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (merge vers: 5.1.39-ndb-7.1.0) (pib:11)
[5 Oct 2009 10:50] Bugs System
Pushed into 5.1.39-ndb-6.2.19 (revid:jonas@mysql.com-20091005103850-dwij2dojwpvf5hi6) (version source revid:jonas@mysql.com-20090930185117-bhud4ek1y0hsj1nv) (merge vers: 5.1.39-ndb-6.2.19) (pib:11)
[8 Oct 2009 2:48] Paul DuBois
The 5.4 fix has been pushed to 5.4.2.