Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails
Submitted: 18 Jan 2008 19:09 Modified: 29 Mar 2008 17:55
Reporter: Andrei Elkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: Andrei Elkin CPU Architecture:Any

[18 Jan 2008 19:09] Andrei Elkin
Description:
When chasing after the reason of Bug #33423 Test 'rpl_server_id2' fails ...
it was found out that io thread might hit the assert
  
DBUG_ASSERT(thd == mi->io_thd);

wheneven one of the functions
   init_thr_lock() || thd->store_globals()
returns non-zero.

It's not clear if this finding reveals the very reason of Bug #33421, Bug #33423.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1265345632 (LWP 2157)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7dbb770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7dbcef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7db4dbb in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
#4  0x083527e3 in write_ignored_events_info_to_relay_log (thd=0x8c82290, 
    mi=0x8caf6e8) at slave.cc:1995
#5  0x08354d9a in handle_slave_io (arg=0x8caf6e8) at slave.cc:3814

How to repeat:
Apply this patch and start a slave server with an existing configuration (that forces the slave to roll up)

===== slave.cc 1.304 vs edited =====
--- 1.304/sql/slave.cc  2007-12-20 17:07:52 +02:00
+++ edited/slave.cc     2008-01-18 20:55:32 +02:00
@@ -2895,6 +2895,9 @@ void set_slave_thread_default_charset(TH
 static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
 {
   DBUG_ENTER("init_slave_thread");
+#if !defined(DBUG_OFF)
+  int simulate_error= 0;
+#endif
   thd->system_thread = (thd_type == SLAVE_THD_SQL) ?
     SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; 
   thd->security_ctx->skip_grants();
@@ -2914,7 +2917,13 @@ static int init_slave_thread(THD* thd, S
   thd->thread_id = thread_id++;
   pthread_mutex_unlock(&LOCK_thread_count);
 
+  DBUG_EXECUTE_IF("simulate_io_slave_error", simulate_error|= (1 << SLAVE_THD_IO););
+  DBUG_EXECUTE_IF("simulate_sql_slave_error", simulate_error|= (1 << SLAVE_THD_SQL););
+#if !defined(DBUG_OFF)
+  if (init_thr_lock() || thd->store_globals() || simulate_error & (1<< thd_type))
+#else
   if (init_thr_lock() || thd->store_globals())
+#endif
   {
     thd->cleanup();
     delete thd;
[4 Feb 2008 21:58] 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/41682

ChangeSet@1.2576, 2008-02-04 23:57:56+02:00, aelkin@koti.dsl.inet.fi +3 -0
  Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails
  and
  bug#33932  assertion at handle_slave_sql if init_slave_thread() fails
  
  the asserts were caused by 
    bug33931: having thd deleted at time of executing err: code plus
              a missed initialization;
    bug33932: initialization of slave_is_running member was missed;
  
  fixed with relocating mi members initialization and removing delete thd
  It is safe to do as deletion happens later.
  
  Todo: at merging the test is better to be moved into suite/bugs for 5.x (when x>0).
[13 Feb 2008 12:10] 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/42210

ChangeSet@1.2576, 2008-02-13 14:09:41+02:00, aelkin@mysql1000.dsl.inet.fi +4 -0
  Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails
  and
  bug#33932  assertion at handle_slave_sql if init_slave_thread() fails
  
  the asserts were caused by 
    bug33931: having thd deleted at time of executing err: code plus
              a missed initialization;
    bug33932: initialization of slave_is_running member was missed;
  
  fixed with relocating mi members initialization and removing delete thd
  It is safe to do as deletion happens later explicitly in the caller of
  init_slave_thread().
  
  Todo: at merging the test is better to be moved into suite/bugs for 5.x (when x>0).
[14 Feb 2008 22:05] Andrei Elkin
Pushed to 5.0-rpl
[25 Mar 2008 11:22] Bugs System
Pushed into 5.0.60
[25 Mar 2008 11:23] Bugs System
Pushed into 5.1.24-rc
[26 Mar 2008 19:00] Bugs System
Pushed into 6.0.5-alpha
[27 Mar 2008 8:18] Andrei Elkin
Asserts fired in a case of having negative results from memory allocation
at thd->store_globals().
The assert condition did not expect that due to the failure in thd->store_globals() execution trace will skip some of necessary initializations.
And that has been corrected.
[29 Mar 2008 17:55] Jon Stephens
No end-user changes to be documented. Closed without further action.
[1 May 2008 5:26] 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/46255

ChangeSet@1.2637, 2008-05-01 07:25:21+02:00, tnurnberg@noir.wlan.koehntopp.de +2 -0
  post-merge fixes for 6.0-bugteam / 6.0-main
  correct test results for Bug#33931
[1 May 2008 6:19] Bugs System
Pushed into 6.0.6-alpha