Bug #86422 lock0lock.cc: ((m_mode - (0xFUL & m_mode)) - (0xF0UL & m_mode) - (256 & m_mode))
Submitted: 23 May 2017 9:00 Modified: 13 Oct 2017 17:00
Reporter: John Embretsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[23 May 2017 9:00] John Embretsen
Description:
InnoDB hits an assertion during CREATE TABLE as follows:

[ERROR] InnoDB: Assertion failure: lock0lock.cc:1436:((m_mode - (0xFUL & m_mode)) - (0xF0UL & m_mode) - (256 & m_mode)) == 1024

Stacktrace:

#2  handle_fatal_signal (sig=6) at sql/signal_handler.cc:231
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  __GI_abort () at abort.c:89
#6  ut_dbg_assertion_failed (expr="((m_mode - (0xFUL & m_mode)) - 
    (0xF0UL & m_mode) - (256 & m_mode)) == 1024", 
    file="storage/innobase/lock/lock0lock.cc", line=1436)
    at storage/innobase/ut/ut0dbg.cc:60
#7  RecLock::create (this=, trx=, owns_trx_mutex=false,
    add_to_hash=true, prdt=)
    at storage/innobase/lock/lock0lock.cc:1436
#8  lock_rec_lock_fast (impl=false, mode=515, block=,
    heap_no=298, index=, thr=)
    at storage/innobase/lock/lock0lock.cc:1803
#9  lock_rec_lock (impl=false, sel_mode=SELECT_ORDINARY, mode=515, block=,
    heap_no=298, index=, thr=)
    at storage/innobase/lock/lock0lock.cc:1982
#10 lock_sec_rec_read_check_and_lock (flags=0, block=, rec="", index=,
    offsets=, sel_mode=SELECT_ORDINARY, mode=LOCK_X, gap_mode=512, 
    thr=) at storage/innobase/lock/lock0lock.cc:6170
#11 row_ins_set_exclusive_rec_lock (type=512, block=, rec="",
    index=, offsets=, thr=)
    at storage/innobase/row/row0ins.cc:1528
#12 row_ins_sec_index_entry_low (flags=0, mode=2, index=, offsets_heap=,
    heap=, entry=, trx_id=0, thr=, dup_chk_only=false)
    at storage/innobase/row/row0ins.cc:3350
#13 row_ins_sec_index_entry (index=, entry=, thr=, dup_chk_only=false)
    at storage/innobase/row/row0ins.cc:3617
#14 row_ins_index_entry (index=, entry=, thr=)
    at storage/innobase/row/row0ins.cc:3666
#15 row_ins_index_entry_step (node=, thr=)
    at storage/innobase/row/row0ins.cc:3811
#16 row_ins (node=, thr=) at storage/innobase/row/row0ins.cc:3953
#17 row_ins_step (thr=) at storage/innobase/row/row0ins.cc:4137
#18 row_insert_for_mysql_using_ins_graph
    (mysql_rec="\370\377\377H\001", prebuilt=)
    at storage/innobase/row/row0mysql.cc:1708
#19 row_insert_for_mysql (mysql_rec="\370\377\377H\001", prebuilt=)
    at storage/innobase/row/row0mysql.cc:1846
#20 ha_innobase::write_row (this=, record="\370\377\377H\001")
    at storage/innobase/handler/ha_innodb.cc:8804
#21 handler::ha_write_row (this=, buf="\370\377\377H\001")
    at sql/handler.cc:8346
#22 dd::Raw_new_record::insert (this=)
    at sql/dd/impl/raw/raw_record.cc:323
#23 dd::Weak_object_impl::store (this=, otx=)
    at sql/dd/impl/types/weak_object_impl.cc:131
#24 dd::cache::Storage_adapter::store<dd::Table> (thd=, object=)
    at sql/dd/impl/cache/storage_adapter.cc:306
#25 dd::cache::Dictionary_client::store<dd::Table> (this=, object=)
    at sql/dd/impl/cache/dictionary_client.cc:2192

Verified against debug build of mysql-trunk (8.0.2) commit da4b76a9 (2017-05-23).
No issue observed against release build of the same code.

How to repeat:
--error ER_NO_DEFAULT_FOR_FIELD
CREATE TEMPORARY TABLE  mytable116 ( `QMd` TEXT NOT NULL) REPLACE AS
  SELECT thread_id, user, total_allocated FROM sys.memory_by_thread_by_current_bytes;
CREATE  TABLE IF NOT EXISTS mytable111 (a INT);
DROP TABLE mytable111;
[24 May 2017 8:07] John Embretsen
Posted by developer:
 
Simplified version of first error-producing statement in How to repeat (no need to reference sys schema):

CREATE TEMPORARY TABLE mytable116 ( `QMd` TEXT NOT NULL) REPLACE AS SELECT 'test' FROM DUAL;
[13 Oct 2017 17:00] Paul DuBois
Posted by developer:
 
Fixed in 8.0.4, 9.0.0.

Failed creation of a temporary table using REPLACE could under some
circumstances result in an assertion in a later statement.