Bug #29632 insert into + analyze bdb table in >1 threads crashes mysqld
Submitted: 8 Jul 2007 22:23 Modified: 23 Jul 2007 18:05
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: BDB Severity:S2 (Serious)
Version:5.0.46BK OS:Any
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: analyze table, bdb, crash

[8 Jul 2007 22:23] Shane Bester
Description:
running analyze table in >1 thread on bdb tables will crash mysqld with this stack trace:

0x81a286f handle_segfault + 529
0x825d5b0 _ZN11ha_berkeley7analyzeEP3THDP15st_ha_check_opt + 120
0x826bdc7 _Z17mysql_admin_tableP3THDP13st_table_listP15st_ha_check_optPKc13thr_lock_typebbjPFiS0_S2_S4_EM7handlerFiS0_S4_EPFiS0_S2_E + 2471
0x826d00d _Z19mysql_analyze_tableP3THDP13st_table_listP15st_ha_check_opt + 105
0x81b8d83 _Z21mysql_execute_commandP3THD + 8059
0x81beb60 _Z11mysql_parseP3THDPKcjPS2_ + 258
0x81b5b8f _Z16dispatch_command19enum_server_commandP3THDPcj + 1713
0x81b54ce _Z10do_commandP3THD + 242
0x81b499f handle_one_connection + 813

How to repeat:
will upload testcase later.

Suggested fix:
as with all other engines, make sure locking strategy has been thought about.
[11 Jul 2007 21:20] MySQL Verification Team
testcase to cause multiple crashes within < 2 seconds

Attachment: bug29632.c (text/plain), 6.26 KiB.

[11 Jul 2007 21:24] MySQL Verification Team
So far, every single storage engine except blackhole has had these DDL concurrency problems.  

Verified using attached testcase.
Build 5.0 using --with-berkeley-db configure option.

sbester@www:~> gcc bug29632.c -g -o bug29632 -L/home/sbester/server/5.0/mysql-5.0.46-linux-i686/lib -I/home/sbester/server/5.0/mysql-5.0.46-linux-i686/include   -lmysqlclient_r -lz -lpthread
sbester@www:~> ./bug29632 
running initializations..
pre-generating 16777216 bytes of random data
about to spawn 5 threads
.....
completed spawning new database worker threads
testcase is now running, so watch for error output
query failed 'insert into t1 values (-1742970,'epejzwycosnejrpwlazomtbgxzaqfrrgomhdgjjcpmkebinblosmfrhcwcsvmaqbcqaebddjfrczswcjtwucjbjjogpwjxolvuvfoxjulcnwbwygobpsqzibzxakrzsapiixhzisffxpqxcngihyvisrbbxydwdzycbqu','2698-07-08 04:20:53')' : 2013 (Lost connection to MySQL server during query)
 ...