Bug #48155 assert in handler::ha_external_lock
Submitted: 19 Oct 2009 16:31 Modified: 8 Jan 2010 13:35
Reporter: Matthias Leich Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:mysql-6.0-codebase-bugfixing OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[19 Oct 2009 16:31] Matthias Leich
Description:
The assertion happens in handler.cc:5496:
   DBUG_ASSERT(next_insert_id == 0);

Backtrace from mysql-6.0-codebase-bugfixing 
revno: 3654 2009-10-15
-------------------------------------------
Thread 1 (process 29262):
#0  0x00007f7110cfe1f6 in pthread_kill () from /lib/libpthread.so.0
#1  0x0000000000b8f05c in my_write_core (sig=6) at stacktrace.c:309
#2  0x00000000006f6f17 in handle_segfault (sig=6) at mysqld.cc:2754
#3  <signal handler called>
#4  0x00007f710fbb2fb5 in raise () from /lib/libc.so.6
#5  0x00007f710fbb4bc3 in abort () from /lib/libc.so.6
#6  0x00007f710fbabf09 in __assert_fail () from /lib/libc.so.6
#7  0x000000000085fdf0 in handler::ha_external_lock (this=0x7f710001c2c0,
    thd=0x31ee048, lock_type=2) at handler.cc:5496
#8  0x00000000006eb8b1 in unlock_external (thd=0x31ee048, table=0x3340f70,
    count=1) at lock.cc:822
#9  0x00000000006ec82f in mysql_unlock_tables (thd=0x31ee048,
    sql_lock=0x3340f48) at lock.cc:437
#10 0x0000000000764f42 in close_thread_tables (thd=0x31ee048)
    at sql_base.cc:1489
#11 0x00000000007650e8 in close_tables_for_reopen (thd=0x31ee048,
    tables=0x7f71044a9c40) at sql_base.cc:5221
#12 0x0000000000768934 in open_tables (thd=0x31ee048, start=0x7f71044a9c40,
    counter=0x7f71044a9c78, flags=0, prelocking_strategy=0x7f71044a9cb0)
    at sql_base.cc:4196
#13 0x0000000000768de5 in open_and_lock_tables_derived (thd=0x31ee048,
    tables=0x7f7100092fc0, derived=true, flags=0,
    prelocking_strategy=0x7f71044a9cb0) at sql_base.cc:4759
#14 0x0000000000715cce in open_and_lock_tables_derived (thd=0x31ee048,
    tables=0x7f7100092fc0, derived=true, flags=0) at ../mysql_priv.h:1518
#15 0x0000000000715d09 in open_and_lock_tables (thd=0x31ee048,
    tables=0x7f7100092fc0) at ../../sql/mysql_priv.h:1528
#16 0x000000000070d3e9 in mysql_execute_command (thd=0x31ee048)
    at sql_parse.cc:3295
#17 0x0000000000907279 in sp_instr_stmt::exec_core (this=0x7f7100094540,
    thd=0x31ee048, nextp=0x7f71044ab768) at sp_head.cc:2921
#18 0x00000000009074a9 in sp_lex_keeper::reset_lex_and_exec_core (
    this=0x7f7100094580, thd=0x31ee048, nextp=0x7f71044ab768,
    open_tables=false, instr=0x7f7100094540) at sp_head.cc:2746
#19 0x000000000090da7e in sp_instr_stmt::execute (this=0x7f7100094540,
    thd=0x31ee048, nextp=0x7f71044ab768) at sp_head.cc:2859
#20 0x00000000009098b4 in sp_head::execute (this=0x7f7100071de0, thd=0x31ee048)
    at sp_head.cc:1243
#21 0x000000000090ae41 in sp_head::execute_trigger (this=0x7f7100071de0,
    thd=0x31ee048, db_name=0x35d93b8, table_name=0x35d93c8,
    grant_info=0x7f7100013b18) at sp_head.cc:1552
#22 0x0000000000919e33 in Table_triggers_list::process_triggers (
    this=0x7f7100013a40, thd=0x31ee048, event=TRG_EVENT_INSERT,
    time_type=TRG_ACTION_AFTER, old_row_is_record1=true) at sql_trigger.cc:2016
#23 0x00000000007bb384 in write_record (thd=0x31ee048, table=0x7f710007c898,
    info=0x7f71044abce0) at sql_insert.cc:1640
#24 0x00000000007bfd53 in mysql_insert (thd=0x31ee048, table_list=0x380d288,
    fields=@0x380cb58, values_list=@0x380cba0, update_fields=@0x380cb88,
    update_values=@0x380cb70, duplic=DUP_REPLACE, ignore=false)
    at sql_insert.cc:834
#25 0x000000000070d248 in mysql_execute_command (thd=0x31ee048)
    at sql_parse.cc:3258
#26 0x00000000007c7ba6 in Prepared_statement::execute (this=0x343b578,
    expanded_query=0x7f71044ad8c0, open_cursor=false) at sql_prepare.cc:3766
#27 0x00000000007cbeda in Prepared_statement::execute_loop (this=0x343b578,
    expanded_query=0x7f71044ad8c0, open_cursor=false, packet=0x0,
    packet_end=0x0) at sql_prepare.cc:3398
#28 0x00000000007cc172 in mysql_sql_stmt_execute (thd=0x31ee048)
    at sql_prepare.cc:2571
#29 0x000000000070a545 in mysql_execute_command (thd=0x31ee048)
    at sql_parse.cc:2131
#30 0x0000000000712b87 in mysql_parse (thd=0x31ee048,
    inBuf=0x37afaf0 "EXECUTE st1", length=11, found_semicolon=0x7f71044af900)
    at sql_parse.cc:5991
#31 0x00000000007137d2 in dispatch_command (command=COM_QUERY, thd=0x31ee048,
    packet=0x37c7349 " EXECUTE st1 ", packet_length=13) at sql_parse.cc:1074
#32 0x0000000000714d3d in do_command (thd=0x31ee048) at sql_parse.cc:756
#33 0x0000000000701784 in handle_one_connection (arg=0x31ee048)
    at sql_connect.cc:1164
#34 0x00007f7110cf93ba in start_thread () from /lib/libpthread.so.0
#35 0x00007f710fc65fcd in clone () from /lib/libc.so.6
#36 0x0000000000000000 in ?? ()

RQG test, WL5004_sql.yy, 30 threads

How to repeat:
I will come up with a simplified replay test case soon.
[10 Nov 2009 12:49] Matthias Leich
Last simplified grammar

Attachment: bug26.yy (application/octet-stream, text), 31.08 KiB.

[10 Nov 2009 12:54] Matthias Leich
The simplification process slowed down because of
some tool weaknesses. I uploaded the last grammar.
The last command line used was
perl runall.pl ... --threads=30 --queries=3000 --duration=60 \
--mysqld=--table-lock-wait-timeout=1 --mysqld=--innodb-lock-wait-timeout=1 --mysqld=--log-output=file --reporter=Deadlock,Backtrace,Shutdown --gendata=conf/WL5004_data.zz --grammar=./conf/bug26.yy ...\
--seed=114
I will restart simplification if I have the time.
[7 Dec 2009 9:17] Philip Stoev
Core and binary 

http://mysql-systemqa.s3.amazonaws.com/var-bug44820.zip

core:

revision-id: alik@sun.com-20091203092413-5tsz2k3tqtev6965
date: 2009-12-03 12:24:13 +0300
build-date: 2009-12-07 11:04:31 +0200
revno: 3752
branch-nick: 6.0-codebase-bugfixing
[7 Dec 2009 11:41] Philip Stoev
Newgrammar for bug 48155

Attachment: bug48155-2.yy (application/octet-stream, text), 30.94 KiB.

[7 Dec 2009 11:44] Philip Stoev
A new grammar for this bug has been attached. It should cause this assertion in 80% of the test runs within a minute. The presence of a mysql slave appears to increase the likelihood of a crash. Please disregard the actual output of the script -- the RQG will print a bunch of messages before terminating with:

# 13:40:06 Server crash reported at dsn dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test

$ perl runall.pl \
  --gendata=conf/WL5004_data.zz \
  --duration=600 \
  --queries=100K \
  --basedir=/build/bzr/6.0-codebase-bugfixing \
  --mysqld=--log-output=file \
  --grammar=conf/bug48155.yy \
  --mem \
  --threads=30 \
  --rpl_mode=row

Please let me know if further simplification is required -- the grammar may perform operations that are not necessary for the bug to appear.
[8 Jan 2010 13:35] Jon Olav Hauglid
Closing this bug as a duplicate of Bug#48246.