Bug #19881 slave cores at close_temporary_tables under shutdown
Submitted: 17 May 2006 12:59 Modified: 18 Aug 2006 21:11
Reporter: Andrei Elkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1.11-beta,5.0.24 OS:Linux (linux)
Assigned to: Andrei Elkin CPU Architecture:Any

[17 May 2006 12:59] Andrei Elkin
Description:
At https://intranet.mysql.com/~knielsen/pb/mysql-5.1-new/1047.html
there is a failure description.

060517 12:58:36 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '/dev/shm/var-n_stm-5/log/slave-relay-bin.000001' position: 4
060517 12:58:36 [Note] Slave I/O thread: connected to master 'root@127.0.0.1:10050',  replication started in log 'FIRST' at position 4
060517 12:58:36 [Note] Slave I/O thread killed while reading event
060517 12:58:36 [Note] Slave I/O thread exiting, read up to log 'master-bin.000001', position 1802
...

How to repeat:
make test
[17 May 2006 18:43] Andrei Elkin
Slave cores to show the following bt:

#3  0x0837fce9 in write_core (sig=23716) at stacktrace.c:220
#4  0x081ee440 in handle_segfault (sig=11) at mysqld.cc:2147
#5  <signal handler called>
#6  close_temporary (table=0x45a0b488, free_share=true, delete_table=false) at sql_base.cc:1561
#7  0x0837120a in st_relay_log_info::close_temporary_tables (this=0x92214f4) at slave.cc:517
#8  0x083713f5 in end_relay_log_info (rli=0x92214f4) at slave.cc:4265
#9  0x083714de in end_master_info (mi=0x9220698) at slave.cc:1414
#10 0x083715c6 in end_slave () at slave.cc:844
#11 0x081f10a9 in kill_server_thread (arg=0x458599cc) at mysqld.cc:886
#12 0x40035a13 in start_thread () from /lib/tls/libpthread.so.0
[17 May 2006 23:37] Lars Thalmann
See also BUG#19073
[19 May 2006 7:31] Andrei Elkin
Finally found a reliable way to catch. Near the segfault there is a warning that
most probable is the key.

Error: Freeing wrong aligned pointer at line 808, 'sql_base.cc'

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1115528112 (LWP 19607)]
0x08245488 in closefrm (table=0x43415fa0, free_share=false) at table.cc:1569
1569        error=table->file->close();
[2 Jun 2006 21:08] Andrei Elkin
I got evidence that memory allocated for temp tables in open_temporary_table got freed by
delete THD when slave sql thread stops e.g for error code of the latest query.
This should not happend as the idea is to clean the tables only when 
a. slave reset
b. slave mysqld exits
This bug reveal there is one more "unspecified" place, which btw does not exist in 5.0

TODO: track down why my_malloc-ed object is freed at ~THD instead of the specified places.
[5 Jun 2006 11:58] Andrei Elkin
Changing the title. The issue emerged at rpl_stm_000001 exectution on SLES-9.
[5 Jun 2006 16:00] 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/7283
[19 Jun 2006 15:51] 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/7864
[19 Jun 2006 16: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/7865
[19 Jun 2006 17:14] 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/7868
[21 Jun 2006 14:22] Lars Thalmann
Pushed into 5.1.12
[22 Jun 2006 7:35] MC Brown
A note has been placed into the Changelog for 5.1 for this item: 

Shutting down a slave in a replication scenario where temporary tables are in use would cause the slave to produce a core dump. (Bug #19881)
[8 Jul 2006 21:29] 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/8956
[18 Aug 2006 21:11] Andrei Elkin
Possible regressions were actually for bug #20919 which has a family of dups
 Bug#21582, Bug#21666, Bug#21609.
The parent has been fixed in main bk-5.0 but appeared not be out of 5.0.24.