Bug #25617 Unhandled exception from Falcon causes a core dump at server shutdown
Submitted: 15 Jan 2007 2:17 Modified: 18 Feb 2007 0:32
Reporter: Mark Callaghan Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S2 (Serious)
Version:5.2 Falcon OS:Linux (Linux 2.4)
Assigned to: CPU Architecture:Any
Tags: core, exception, F_SHUTDOWN

[15 Jan 2007 2:17] Mark Callaghan
Description:
This is from Linux 2.4.
Default values were used for Falcon configuration variables.
Server was built using '--without-debug'

070114 18:05:59 [Note] /export/hda3/mysql5-falcon/libexec/mysqld: Normal shutdown
 
From the error log:

070114 18:05:59 [Note] SCHEDULER: Purging queue. 0 events
terminate called after throwing an instance of 'SQLError'
mysqld got signal 6;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
 
key_buffer_size=8388600
read_buffer_size=131072
max_used_connections=1
max_connections=151
threads_connected=0

The stack trace:

0x4e7dc2b9 << abort  ??:0  libc.so.6 >>
0x4ecd821e << __gnu_cxx::__verbose_terminate_handler  ??:0  libstdc++.so.6 >>
0x4ecd5f15 << __gxx_personality_v0  ??:0  libstdc++.so.6 >>
0x4ecd5f4a << std::terminate  ??:0  libstdc++.so.6 >>
0x4ecd5f5f << std::terminate  ??:0  libstdc++.so.6 >>
0x4ecd5a18 << __cxa_call_unexpected  ??:0  libstdc++.so.6 >>
0x083ac938 << SerialLog::~SerialLog  ??:0  mysqld >>
0x08356089 << Database::~Database  ??:0  mysqld >>
0x0832e8f0 << StorageDatabase::close  ??:0  mysqld >>
0x0832f985 << StorageHandler::shutdownHandler  ??:0  mysqld >>
0x08321fbf << NfsStorageTable::panic  ??:0  mysqld >>
0x082a7b02 << ha_finalize_handlerton  ??:0  mysqld >>
0x0831c5a5 << plugin_shutdown  ??:0  mysqld >>
0x081d4d7c << clean_up  mysqld.cc:0  mysqld >>
0x081da59f << kill_server_thread  ??:0  mysqld >>
0x4ea14341 << start_thread  ??:0  libpthread.so.0 >>
0x4e87b4ee << clone  ??:0  libc.so.6 >>

How to repeat:
bin/mysqld_safe &
run some queries
bin/mysqladmin -uroot shutdown

Suggested fix:
Don't use C++ exceptions (only kidding)
[16 Jan 2007 16:33] Hakan Küçükyılmaz
Can't repeat with debug build. Now trying non debug build.
[16 Jan 2007 16:50] Mark Callaghan
Given that the exception comes from SerialLog, the test case might need inserts between startup and shutdown and enough inserts that there are flushes pending from the serial log at shutdown.
[16 Jan 2007 20:27] Mark Callaghan
My test case:
1) start with empty database (delete any falcon files)
2) start MySQL
3) create test table
CREATE TABLE C (
  ChId bigint(20) NOT NULL default '0',
  Timestamp datetime NOT NULL default '0000-00-00 00:00:00',
  CuId int(11) NOT NULL default '0',
  CaId int(11) NOT NULL default '0',
  AId int(11) NOT NULL default '0',
  UId int(11) NOT NULL default '0',
  IpAddress varchar(15) NOT NULL default '',
        primary key (ChId)
) engine=Falcon;

4) run python to generate test data in var/test/o.gen
import random

a=[]
for i in xrange(5000000): a.append(i)
random.shuffle(a)

for i in a:
  j = i + 1000000
  print "%d,2006-01-01,%d,%d,%d,%d,12.34.56.78" % (i,j,j,j,j)

5) insert data
 load data infile 'o.gen' into table C fields terminated by ',';

6) wait 30 seconds

7) bin/mysqladmin -uroot -p shutdown
(this takes a while, I think Falcon delays shutdown until serial log is flushed)

8) core dump

Server built without debugging
Non-default config variables are:
[mysqld]
innodb_flush_log_at_trx_commit = 2
set-variable   = innodb_log_files_in_group=3
set-variable   = innodb_log_buffer_size=10M
set-variable   = innodb_additional_mem_pool_size=50M
set-variable   = innodb_file_io_threads=4
set-variable   = innodb_lock_wait_timeout=50
innodb_data_file_path = innodb_data1:16M:autoextend
set-variable   = innodb_buffer_pool_size=100M
set-variable   = innodb_log_file_size=200M

falcon_max_record_memory=400M
falcon_page_cache_size=1000M
[16 Jan 2007 21:32] Hakan Küçükyılmaz
Verified with slight different test case. I used a stored procudure for the data loading.

Problem is that I already get a crash while data loading.

Here is the stored procedure I used:

--
-- Insert six million rows.
--
-- Original script by Peter Gulutzan.

delimiter //
create table tt (s1 int, s2 char(100), s3 blob) engine falcon//
create procedure pt ()
 begin
   declare v int default 0;
   while v < 6000000 do
     if v mod 10000 = 0 then
       select v;
       commit;
       start transaction;
     end if;
     insert into tt values (v,'',repeat('a',900));
     set v = v + 1;
   end while;
 end//
set @@autocommit=0//
start transaction//
call pt()//
commit//

The last commit// is never reached and I get:

+---------+
| v       |
+---------+
| 3990000 |
+---------+
1 row in set (14 min 56.66 sec)

ERROR 2013 (HY000): Lost connection to MySQL server during query
5.2.1-falcon-alpha

Resolved stack trace is:
lu0008:/data/mysql-sap # resolve_stack_dump -s /tmp/mysqld.sym -n /tmp/mysqld.stack | c++filt
0x824109f handle_segfault + 543
0xffffe410 _end + -143440416
0x83f632d Error::error(char const*, ...) + 77
0x840a713 IO::writePage(Bdb*) + 227
0x845ab29 Cache::writePage(Bdb*) + 57
0x841a8f7 PageWriter::writer() + 167
0x83cb570 Thread::thread() + 80
0x83cb7a0 Thread::thread(void*) + 16
0x40284297 _end + 932947047
0x4021937e _end + 932509006

Thank you for your bug report!

Best regards, Hakan
[17 Jan 2007 2:06] Hakan Küçükyılmaz
Sorry, my crash was due to full disk.

I tried your data load on a 4-way Intel with 8 GB RAM running SLES 9.
I did the following:

1) Started with empty database (delete any falcon files)

2) Started mysqld with mysqld_safe (5.2.1-falcon-alpha)

3) Created test table C

4) Populated o.gen

5) Ran "load data infile 'o.gen' into table C fields terminated by ',';"
mysql> load data infile 'o.gen' into table C fields terminated by ',';
Query OK, 5000000 rows affected (1 min 59.50 sec)
Records: 5000000  Deleted: 0  Skipped: 0  Warnings: 0

6) Waited > 30 sec but less than 1 minute

7) Shut down mysqld with mysqladmin shutdown

I cannot reproduce a crash.

Which version of MySQL are you running?

Best regards, Hakan
[17 Jan 2007 2:13] Mark Callaghan
Is this sufficient?

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.14-falcon-alpha Source distribution
[17 Jan 2007 2:16] Hakan Küçükyılmaz
Yes, that's sufficient. I think we fixed this issue already. Please try latest Falcon from
  http://dev.mysql.com/downloads/mysql/5.2.html

Thanks, Hakan
[17 Jan 2007 2:44] Mark Callaghan
I just downloaded and built 5.2 without debugging and get the same crash. Fortunately, another bug I filed from 5.1.14 seems to have been fixed (drop table blocks on flushes from the Falcon serial log)

mysql> select version();
+--------------------+
| version()          |
+--------------------+
| 5.2.0-falcon-alpha |
+--------------------+
[18 Jan 2007 0:32] Hakan Küçükyılmaz
I can't reproduce it with 5.2.0-falcon-alpha. I tried two variations;

1) Let the load data infile finish and then issue the shutdown
2) Shutdown the server after 30 seconds after load data infile started.

Both time no crash for me. 

mysql> load data infile 'o.gen' into table C fields terminated by ',';                                       ERROR 2013 (HY000): Lost connection to MySQL server during query                                             mysql>                                                                                                       mysql> Bye
lu0010:/data/mysql #
lu0010:/data/mysql #
lu0010:/data/mysql # ls
.  ..  lu0010.err  lu0010.pid  mysql  test  test.fl1  test.fl2  test.fts
lu0010:/data/mysql # tail -f lu0010.err
070118 01:27:49  mysqld started
070118  1:27:49 [Note] /usr/local/mysql-5.1/libexec/mysqld: ready for connections.
Version: '5.2.0-falcon-alpha'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
070118  1:27:49 [Note] SCHEDULER: Loaded 0 events
database open failed: can't open file "/data/mysql/test.fts": No such file or directory (2)
070118  1:29:07 [Note] /usr/local/mysql-5.1/libexec/mysqld: Normal shutdown

070118  1:29:07 [Note] SCHEDULER: Purging queue. 0 events
070118  1:29:09 [Warning] /usr/local/mysql-5.1/libexec/mysqld: Forcing close of thread 2  user: 'root'

070118  1:29:37 [Note] /usr/local/mysql-5.1/libexec/mysqld: Shutdown complete

STOPPING server from pid file /data/mysql/lu0010.pid
070118 01:29:37  mysqld ended

070118 01:29:37  mysqld ended

[1]+  Done                    mysqld_safe
lu0010:/data/mysql #

Can you provide me your build options?
[19 Feb 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".