Bug #92068 InnoDB: Assertion failure: lock0lock.cc:1468:lock_rec_get_rec_not_gap(lock)

Submitted: 19 Aug 2018 21:58 Modified: 5 Sep 2019 12:21
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S1 (Critical)
Version:8.0.12 OS:Any
Assigned to: CPU Architecture:Any

[19 Aug 2018 21:58] Roel Van de Paar
Description:
2018-08-19T21:54:17.715063Z 8 [ERROR] [MY-000000] [InnoDB] InnoDB: Assertion failure: lock0lock.cc:1468:lock_rec_get_rec_not_gap(lock)
InnoDB: thread 140153661400832
InnoDB: We intentionally generate a memory trap.

How to repeat:
# mysqld options required for replay: --sql_mode= 
CREATE DATABASE test;
USE test;
CREATE TABLE t0(a INT,b INT KEY,KEY (a));
create view v0 as select a FROM t0;
DROP TABLE t0;
create table t0(a int,b date,c date)replace SELECT 0 as b;
[19 Aug 2018 21:58] Roel Van de Paar
Core was generated by `/sda/MS300718-mysql-8.0.12-linux-x86_64-debug/bin/mysqld --no-defaults --core-f'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
57	../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
[Current thread is 1 (Thread 0x7f781133a700 (LWP 17502))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x00005624bbbca78d in my_write_core (sig=6) at /git/MS-8.0.12_dbg/mysys/stacktrace.cc:278
#2  0x00005624ba91ed94 in handle_fatal_signal (sig=6) at /git/MS-8.0.12_dbg/sql/signal_handler.cc:249
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007f781137b801 in __GI_abort () at abort.c:79
#6  0x00005624bbfb4239 in ut_dbg_assertion_failed (expr=0x5624bd19ee28 "lock_rec_get_rec_not_gap(lock)", 
    file=0x5624bd19e580 "/git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc", line=1468)
    at /git/MS-8.0.12_dbg/storage/innobase/ut/ut0dbg.cc:90
#7  0x00005624bbdc192d in RecLock::create (this=0x7f7811331730, trx=0x7f77fb0008d0, add_to_hash=true, prdt=0x0)
    at /git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc:1468
#8  0x00005624bbdc294b in lock_rec_add_to_queue (type_mode=547, block=0x7f77f0a512a8, heap_no=319, index=0x7f77f01b1bb8, 
    trx=0x7f77fb0008d0) at /git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc:1770
#9  0x00005624bbdc3440 in lock_rec_lock_slow (impl=0, sel_mode=SELECT_ORDINARY, mode=515, block=0x7f77f0a512a8, heap_no=319, 
    index=0x7f77f01b1bb8, thr=0x7f77e2dbd538) at /git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc:1933
#10 0x00005624bbdc3809 in lock_rec_lock (impl=false, sel_mode=SELECT_ORDINARY, mode=515, block=0x7f77f0a512a8, heap_no=319, 
    index=0x7f77f01b1bb8, thr=0x7f77e2dbd538) at /git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc:1993
#11 0x00005624bbdcef0a in lock_sec_rec_read_check_and_lock (flags=0, block=0x7f77f0a512a8, rec=0x7f77f1cc69e1 "", 
    index=0x7f77f01b1bb8, offsets=0x7f7811331b00, sel_mode=SELECT_ORDINARY, mode=LOCK_X, gap_mode=512, thr=0x7f77e2dbd538)
    at /git/MS-8.0.12_dbg/storage/innobase/lock/lock0lock.cc:6040
#12 0x00005624bbea3ec1 in row_ins_set_exclusive_rec_lock (type=512, block=0x7f77f0a512a8, rec=0x7f77f1cc69e1 "", 
    index=0x7f77f01b1bb8, offsets=0x7f7811331b00, thr=0x7f77e2dbd538) at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:1337
#13 0x00005624bbea86a3 in row_ins_sec_index_entry_low (flags=0, mode=2, index=0x7f77f01b1bb8, offsets_heap=0x7f77e2c5d818, 
    heap=0x7f77e2c5dd18, entry=0x7f77e2c3dcb8, trx_id=0, thr=0x7f77e2dbd538, dup_chk_only=false)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:2983
#14 0x00005624bbea9148 in row_ins_sec_index_entry (index=0x7f77f01b1bb8, entry=0x7f77e2c3dcb8, thr=0x7f77e2dbd538, 
    dup_chk_only=false) at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:3217
#15 0x00005624bbea92ef in row_ins_index_entry (index=0x7f77f01b1bb8, entry=0x7f77e2c3dcb8, thr=0x7f77e2dbd538)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:3263
#16 0x00005624bbea98e1 in row_ins_index_entry_step (node=0x7f77e2d1ac88, thr=0x7f77e2dbd538)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:3395
#17 0x00005624bbea9c8f in row_ins (node=0x7f77e2d1ac88, thr=0x7f77e2dbd538)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:3517
#18 0x00005624bbeaa2cb in row_ins_step (thr=0x7f77e2dbd538) at /git/MS-8.0.12_dbg/storage/innobase/row/row0ins.cc:3683
#19 0x00005624bbec7eff in row_insert_for_mysql_using_ins_graph (mysql_rec=0x7f77e2d14028 " \317\366\r\017", prebuilt=0x7f77e2d1a0b8)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0mysql.cc:1556
#20 0x00005624bbec8566 in row_insert_for_mysql (mysql_rec=0x7f77e2d14028 " \317\366\r\017", prebuilt=0x7f77e2d1a0b8)
    at /git/MS-8.0.12_dbg/storage/innobase/row/row0mysql.cc:1685
#21 0x00005624bbcf4f4e in ha_innobase::write_row (this=0x7f77e2d12028, record=0x7f77e2d14028 " \317\366\r\017")
    at /git/MS-8.0.12_dbg/storage/innobase/handler/ha_innodb.cc:7629
#22 0x00005624baab0a54 in handler::ha_write_row (this=0x7f77e2d12028, buf=0x7f77e2d14028 " \317\366\r\017")
    at /git/MS-8.0.12_dbg/sql/handler.cc:7478
#23 0x00005624bba319dd in dd::Raw_new_record::insert (this=0x7f77e2caa250) at /git/MS-8.0.12_dbg/sql/dd/impl/raw/raw_record.cc:311
#24 0x00005624bbad90c5 in dd::Weak_object_impl::store (this=0x7f77e2daaa00, otx=0x7f7811333420)
    at /git/MS-8.0.12_dbg/sql/dd/impl/types/weak_object_impl.cc:124
#25 0x00005624bb8883a0 in dd::Collection<dd::Column*>::store_items (this=0x7f77e2de8918, otx=0x7f7811333420)
    at /git/MS-8.0.12_dbg/sql/dd/collection.cc:220
#26 0x00005624bba8aedf in dd::Abstract_table_impl::store_children (this=0x7f77e2de88c0, otx=0x7f7811333420)
    at /git/MS-8.0.12_dbg/sql/dd/impl/types/abstract_table_impl.cc:110
#27 0x00005624bbad3777 in dd::View_impl::store_children (this=0x7f77e2de88c0, otx=0x7f7811333420)
    at /git/MS-8.0.12_dbg/sql/dd/impl/types/view_impl.cc:110
#28 0x00005624bbad8fd4 in dd::Weak_object_impl::store (this=0x7f77e2de88c0, otx=0x7f7811333420)
    at /git/MS-8.0.12_dbg/sql/dd/impl/types/weak_object_impl.cc:110
#29 0x00005624bba1a0ec in dd::cache::Storage_adapter::store<dd::View> (thd=0x7f77e2c23000, object=0x7f77e2de8950)
    at /git/MS-8.0.12_dbg/sql/dd/impl/cache/storage_adapter.cc:296
[19 Aug 2018 21:59] Roel Van de Paar
#30 0x00005624bb915c7c in dd::cache::Dictionary_client::update<dd::View> (this=0x7f77e2c49000, new_object=0x7f77e2de8950)
    at /git/MS-8.0.12_dbg/sql/dd/impl/cache/dictionary_client.cc:2491
#31 0x00005624bb8dcbe2 in dd::update_view (thd=0x7f77e2c23000, new_view=0x7f77e2de8950, view=0x7f77e2e459a8)
    at /git/MS-8.0.12_dbg/sql/dd/dd_view.cc:600
#32 0x00005624baa35f73 in open_views_and_update_metadata (thd=0x7f77e2c23000, views=0x7f7811335b10, commit_dd_changes=false, 
    uncommitted_tables=0x7f7811336c30) at /git/MS-8.0.12_dbg/sql/dd_sql_view.cc:508
#33 0x00005624baa36d11 in update_view_metadata<dd::View_table> (thd=0x7f77e2c23000, db=0x7f77e2ebd810 "test", 
    tbl_or_sf_name=0x7f77e2ebca10 "t0", commit_dd_changes=false, uncommitted_tables=0x7f7811336c30)
    at /git/MS-8.0.12_dbg/sql/dd_sql_view.cc:661
#34 0x00005624baa36727 in update_referencing_views_metadata (thd=0x7f77e2c23000, db=0x7f77e2ebd810 "test", 
    table_name=0x7f77e2ebca10 "t0", new_db=0x0, new_table_name=0x0, commit_dd_changes=false, uncommitted_tables=0x7f7811336c30)
    at /git/MS-8.0.12_dbg/sql/dd_sql_view.cc:678
#35 0x00005624baa3688a in update_referencing_views_metadata (thd=0x7f77e2c23000, table=0x7f77e2ebd288, new_db=0x0, 
    new_table_name=0x0, commit_dd_changes=false, uncommitted_tables=0x7f7811336c30) at /git/MS-8.0.12_dbg/sql/dd_sql_view.cc:700
#36 0x00005624baa36904 in update_referencing_views_metadata (thd=0x7f77e2c23000, table=0x7f77e2ebd288, commit_dd_changes=false, 
    uncommitted_tables=0x7f7811336c30) at /git/MS-8.0.12_dbg/sql/dd_sql_view.cc:708
#37 0x00005624bad2fe97 in Query_result_create::send_eof (this=0x7f77e2dad028) at /git/MS-8.0.12_dbg/sql/sql_insert.cc:2828
#38 0x00005624bad063f7 in JOIN::exec (this=0x7f77e2e45410) at /git/MS-8.0.12_dbg/sql/sql_executor.cc:256
#39 0x00005624ba7d24a2 in handle_query (thd=0x7f77e2c23000, lex=0x7f77e2c28800, result=0x7f77e2dad028, added_options=268435456, 
    removed_options=0) at /git/MS-8.0.12_dbg/sql/sql_select.cc:199
#40 0x00005624bad002e1 in Sql_cmd_create_table::execute (this=0x7f77e2ebdaa8, thd=0x7f77e2c23000)
    at /git/MS-8.0.12_dbg/sql/sql_cmd_ddl_table.cc:298
#41 0x00005624ba772536 in mysql_execute_command (thd=0x7f77e2c23000, first_level=true) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:3228
#42 0x00005624ba777f94 in mysql_parse (thd=0x7f77e2c23000, parser_state=0x7f7811339330) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:4925
#43 0x00005624ba76daeb in dispatch_command (thd=0x7f77e2c23000, com_data=0x7f7811339c90, command=COM_QUERY)
    at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1607
#44 0x00005624ba76c3c6 in do_command (thd=0x7f77e2c23000) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1232
#45 0x00005624ba90c678 in handle_connection (arg=0x7f77febbb480)
    at /git/MS-8.0.12_dbg/sql/conn_handler/connection_handler_per_thread.cc:308
#46 0x00005624bc27b422 in pfs_spawn_thread (arg=0x7f7804be7720) at /git/MS-8.0.12_dbg/storage/perfschema/pfs.cc:2836
#47 0x00007f7812d676db in start_thread (arg=0x7f781133a700) at pthread_create.c:463
#48 0x00007f781145c88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
[20 Aug 2018 4:26] MySQL Verification Team
Hello Roel,

Thank you for the report and test case.
Observed that 8.0.12 debug build is affected.

regards,
Umesh
[20 Aug 2018 4:29] MySQL Verification Team
-- 5.7.23 build not affected
[17 May 2019 13:41] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.17 release, and here's the changelog entry:

 A CREATE TABLE ... REPLACE SELECT operation raised a
lock_rec_get_rec_not_gap(lock) assertion failure. The operation set a flag
on the transaction object indicating that a REPLACE operation was
requested, but did not clear the flag before updating dependent views,
causing a subsequent INSERT operation to be interpreted as a REPLACE
operation, leading to the wrong row locks being taken.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.042 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.