Bug #5546 mysqld crash on PURGE MASTER LOGS BEFORE '...' with log-bin off
Submitted: 13 Sep 2004 16:30 Modified: 15 Sep 2004 9:19
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.4 OS:Linux (linux/freebsd)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[13 Sep 2004 16:30] Harrison Fisk
Description:
mysqld will crash if you attempt a PURGE MASTER LOGS using the new BEFORE syntax while binary logging is turned off.  There was a similar bug (#733) reported before with the TO syntax, so I would assume it is related.

The following backtrace is generated if needed:

shell> resolve_stack_dump -s /tmp/mysqld.sym -n trace.txt
0x808a183 handle_segfault + 423
0x82d3cb8 pthread_sighandler + 184
0x82a5b21 reinit_io_cache + 65
0x80d791f find_log_pos__9MYSQL_LOGP11st_log_infoPCcb + 155
0x80d80d7 purge_logs_before_date__9MYSQL_LOGl + 75
0x81225bf purge_master_logs_before_date__FP3THDl + 27
0x809964c mysql_execute_command__FP3THD + 2376
0x809d8f9 mysql_parse__FP3THDPcUi + 169
0x8097e4f dispatch_command__F19enum_server_commandP3THDPcUi + 1643
0x80977d8 do_command__FP3THD + 188
0x8096f17 handle_one_connection + 615
0x82d146c pthread_start_thread + 220
0x82fa9fa thread_start + 4

How to repeat:
harry:(none)~> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

harry:(none)~> purge master logs before '2003-01-02';
ERROR 2013 (HY000): Lost connection to MySQL server during query

Suggested fix:
I would assume fix is similar to check in the other syntax of PURGE MASTER LOGS as was done for bug #733.
[14 Sep 2004 10:42] Alexander Keremidarski
(gdb) bt
#0  0x083d5565 in reinit_io_cache (info=0x858b264, type=READ_CACHE, seek_offset=0, use_async_io=0 '\0', clear_cache=0 '\0') at mf_iocache.c:303
#1  0x081d7b5b in MYSQL_LOG::find_log_pos(st_log_info*, char const*, bool) (this=0x858b0e0, linfo=0x4114ff70, log_name=0x0, need_lock=false) at log.cc:511
#2  0x081d87b9 in MYSQL_LOG::purge_logs_before_date(long) (this=0x858b0e0, purge_time=1041458400) at log.cc:912
#3  0x0824cd83 in purge_master_logs_before_date(THD*, long) (thd=0x0, purge_time=0) at sql_repl.cc:309
#4  0x08183a56 in mysql_execute_command(THD*) (thd=0x86060a0) at sql_parse.cc:2122
#5  0x08188be9 in mysql_parse(THD*, char*, unsigned) (thd=0x86060a0, inBuf=0x861a1a0 "purge master logs before '2003-01-02'", length=140533976) at sql_parse.cc:4051
#6  0x08181d25 in dispatch_command(enum_server_command, THD*, char*, unsigned) (command=COM_QUERY, thd=0x86060a0, packet=0x8612141 "purge master logs before '2003-01-02'", packet_length=38) at sql_parse.cc:1457
#7  0x0818163f in do_command(THD*) (thd=0x86060a0) at sql_parse.cc:1272
#8  0x08180b22 in handle_one_connection (arg=0x0) at sql_parse.cc:1016
#9  0x4db6198c in start_thread () from /lib/tls/libpthread.so.0
#10 0x4d9e316a in clone () from /lib/tls/libc.so.6
[15 Sep 2004 9:19] Ramil Kalimullin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html