Bug #29420 crash with show and purge binlogs
Submitted: 28 Jun 2007 13:25 Modified: 11 Jul 2007 17:07
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.20 5.0.44/5.0.21 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: binlog, crash

[28 Jun 2007 13:25] Martin Friebe
Description:
using "show binlog events" on a non existing log, followed by purge does crash the server.

How to repeat:
# start a mysql server with binloging, make sure there is a binlog on disk

show binlog events in 'non existing_binlog_file'; # or '' empty string as binlog
purge master logs before now(); # crash

Suggested fix:

0x284fb31b in pthread_testcancel () from /usr/lib/libpthread.so.1
#1  0x284e61dd in pthread_kill () from /usr/lib/libpthread.so.1
#2  0x0821b6ce in write_core (sig=11) at stacktrace.c:231
#3  0x080ed52b in handle_segfault (sig=11) at mysqld.cc:2274
#4  0x284ea8fc in sigaction () from /usr/lib/libpthread.so.1
#5  0xbfbfff94 in ?? ()
#6  0x0000000b in ?? ()
#7  0xbfa33ff0 in ?? ()
#8  0xbfa33d30 in ?? ()
#9  0x00000000 in ?? ()
#10 0x284ea560 in sigaction () from /usr/lib/libpthread.so.1
#11 0x284f0a53 in pthread_mutex_lock () from /usr/lib/libpthread.so.1
#12 0x083900d1 in safe_mutex_lock (mp=0xbfa34120, file=0x844dcb8 "sql_repl.cc", line=220) at thr_mutex.c:106
#13 0x0820c1cb in log_in_use (log_name=0xbfa34194 "/home/martin/mysql/data50a/bin.000001") at sql_repl.cc:220
#14 0x0817d929 in MYSQL_BIN_LOG::purge_logs_before_date (this=0x85bdc60, purge_time=1183036468) at log.cc:3123
#15 0x0820c390 in purge_master_logs_before_date (thd=0xa365000, purge_time=1183036468) at sql_repl.cc:283
#16 0x080f8f79 in mysql_execute_command (thd=0xa365000) at sql_parse.cc:1900
#17 0x0810068b in mysql_parse (thd=0xa365000, inBuf=0xa3c1010 "purge master logs before now()", length=3215149556, found_semicolon=0xbfa34acc) at sql_parse.cc:5388
#18 0x080f73ca in dispatch_command (command=COM_QUERY, thd=0xa365000, packet=0xa3b5001 "purge master logs before now()", packet_length=31) at sql_parse.cc:909
#19 0x080f6bb0 in do_command (thd=0xa365000) at sql_parse.cc:668
#20 0x080f585b in handle_one_connection (arg=0x0) at sql_connect.cc:1094
#21 0x284f3902 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1
[28 Jun 2007 13:43] Miguel Solorzano
Thank you for the bug report. Verified as described.

070628 10:36:34 [Note] libexec/mysqld: ready for connections.
Version: '5.1.21-beta-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
safe_mutex: Trying to lock unitialized mutex at sql_repl.cc, line 189
070628 10:37:39 - mysqld got signal 6;

[miguel@light 5.1]$ bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.21-beta-debug-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show binlog events in 'non existing_binlog_file';
ERROR 1220 (HY000): Error when executing command SHOW BINLOG EVENTS: Could not find target log
mysql> purge master logs before now();
ERROR 2013 (HY000): Lost connection to MySQL server during query
[5 Jul 2007 8: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/30352

ChangeSet@1.2519, 2007-07-05 13:09:56+05:00, ramil@mysql.com +3 -0
  Fix for bug #29420: crash with show and purge binlogs
  
  Problem: in case of failed 'show binlog events...' we don't inform that 
  the log is not in use anymore. That may confuse following 'purge logs...'
  command as it takes into account logs in use.
  
  Fix: always notify that the log is not in use anymore.
[6 Jul 2007 13:57] Chuck Bell
Ok to push. Nice job!
[10 Jul 2007 13:26] Bugs System
Pushed into 5.1.21-beta
[10 Jul 2007 13:28] Bugs System
Pushed into 5.0.46
[11 Jul 2007 17:06] Paul Dubois
Noted in 5.0.46, 5.1.21 changelogs.

Use of SHOW BINLOG EVENTS for a non-existent log file followed by
PURGE MASTER LOGS caused a server crash.