Bug #37873 Client gets ok from INSERT VALUES before commit record is on disk
Submitted: 4 Jul 2008 14:00 Modified: 11 Jul 2008 8:58
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Maria storage engine Severity:S3 (Non-critical)
Version:5.1-maria OS:Any
Assigned to: Guilhem Bichot CPU Architecture:Any

[4 Jul 2008 14:00] Guilhem Bichot
Description:
Put a breakpoint in translog_write_record(), and run
create table t(a int) engine=maria;
insert into t values(2);
Then you will see that client gets OK before gdb enters translog_write_record() for the COMMIT record, this breaks ACID. In other words, gdb first stops at:

Breakpoint 2, net_send_ok (thd=0x9181130, server_status=2, total_warn_count=0, 
    affected_rows=1, id=0, message=0x9181ece "") at protocol.cc:127
127       NET *net= &thd->net;
(gdb) bt
#0  net_send_ok (thd=0x9181130, server_status=2, total_warn_count=0, 
    affected_rows=1, id=0, message=0x9181ece "") at protocol.cc:127
#1  0x0822c541 in net_end_statement (thd=0x9181130) at protocol.cc:411
#2  0x0824e211 in dispatch_command (command=COM_QUERY, thd=0x9181130, 
    packet=0x91a83a9 "insert into t values(2)", packet_length=23)
    at sql_parse.cc:1499
#3  0x0824e692 in do_command (thd=0x9181130) at sql_parse.cc:789
#4  0x0823dd99 in handle_one_connection (arg=0x9181130) at sql_connect.cc:1115
#5  0xb7ecc112 in start_thread () from /lib/libpthread.so.0
#6  0xb7dd12ee in clone () from /lib/libc.so.6

which is a function which sends the OK, so when leaving the function the client prints
Query OK, 1 row affected (1 min 33.66 sec)
and then gdb comes to:
Breakpoint 1, translog_write_record (lsn=0xb69b8aa0, type=LOGREC_COMMIT, 
    trn=0x91ba658, tbl_info=0x0, rec_len=0, part_no=2, parts_data=0xb69b8a90, 
    store_share_id=0x0, hook_arg=0x0) at ma_loghandler.c:6035
6035      uint short_trid= trn->short_id;
Current language:  auto; currently c
(gdb) bt
#0  translog_write_record (lsn=0xb69b8aa0, type=LOGREC_COMMIT, trn=0x91ba658, 
    tbl_info=0x0, rec_len=0, part_no=2, parts_data=0xb69b8a90, 
    store_share_id=0x0, hook_arg=0x0) at ma_loghandler.c:6035
#1  0x0856c737 in ma_commit (trn=0x91ba658) at ma_commit.c:60
#2  0x0850ac1a in ha_maria::external_lock (this=0x91b9d38, thd=0x9181130, 
    lock_type=2) at ha_maria.cc:2337
#3  0x083289c1 in handler::ha_external_lock (this=0x91b9d38, thd=0x9181130, 
    lock_type=2) at handler.cc:4483
#4  0x0822e10e in unlock_external (thd=0x9181130, table=<value optimized out>, 
    count=1) at lock.cc:786
#5  0x0822e312 in mysql_unlock_tables (thd=0x9181130, sql_lock=0x91b9398)
    at lock.cc:389
#6  0x0827f393 in close_thread_tables (thd=0x9181130) at sql_base.cc:1391
#7  0x0824e22b in dispatch_command (command=COM_QUERY, thd=0x9181130, 
    packet=0x91a83a9 "", packet_length=23) at sql_parse.cc:1504
#8  0x0824e692 in do_command (thd=0x9181130) at sql_parse.cc:789

Table unlocking (which is the commit in Maria) happens after sending OK...
This looks like a parent of BUG#36258.
Affects 6.0-maria too.

How to repeat:
see description.
[8 Jul 2008 21:50] Guilhem Bichot
INSERT VALUES, INSERT SELECT, DELETE, UPDATE, all affected.
[11 Jul 2008 8:58] Guilhem Bichot
http://lists.mysql.com/maria/112
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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html
[24 Jul 2008 8:26] Bugs System
Pushed into 6.0.7-alpha  (revid:kpettersson@mysql.com-20080724082624-59z1hc8un6mxdb46) (pib:2)
[14 Sep 2008 4:06] Bugs System
Pushed into 6.0.6-alpha  (revid:guilhem@mysql.com-20080709204746-ntesa1p9t2a0k1ig) (version source revid:hakan@mysql.com-20080716175219-8unfm2ikarselqpw) (pib:3)