|
At the time the record lock was created, we had index->online_status=0 but index->uncommitted. During the record lock creation, the ALTER TABLE was waiting for a metadata lock in the SQL layer:
|
mariadb-10.6.0
|
#14 0x000055a7895fee54 in MDL_wait::timed_wait (this=0x62b00023e348, owner=0x62b00023e2f8, abs_timeout=0x46fc39e22bf0, set_status_on_timeout=true, wait_state_name=0x55a78c4d0b10 <MDL_key::m_namespace_to_wait_state_name+48>) at /data/Server/10.6alpha/sql/mdl.cc:1166
|
#15 0x000055a7896031d5 in MDL_context::acquire_lock (this=0x62b00023e348, mdl_request=0x46fc39e22d40, lock_wait_timeout=2) at /data/Server/10.6alpha/sql/mdl.cc:2356
|
#16 0x000055a789603cec in MDL_context::upgrade_shared_lock (this=0x62b00023e348, mdl_ticket=0x607000091e30, new_type=MDL_EXCLUSIVE, lock_wait_timeout=2) at /data/Server/10.6alpha/sql/mdl.cc:2535
|
#17 0x000055a789092643 in wait_while_table_is_used (thd=0x62b00023e218, table=0x619000642898, function=HA_EXTRA_PREPARE_FOR_RENAME) at /data/Server/10.6alpha/sql/sql_base.cc:1311
|
#18 0x000055a789472337 in mysql_inplace_alter_table (thd=0x62b00023e218, table_list=0x62b000245438, table=0x619000642898, altered_table=0x46fc39e24840, ha_alter_info=0x46fc39e24150, target_mdl_request=0x46fc39e24240, alter_ctx=0x46fc39e252b0) at /data/Server/10.6alpha/sql/sql_table.cc:8133
|
#19 0x000055a78948476b in mysql_alter_table (thd=0x62b00023e218, new_db=0x62b000242c38, new_name=0x62b000243060, create_info=0x46fc39e26640, table_list=0x62b000245438, alter_info=0x46fc39e26510, order_num=0, order=0x0, ignore=false, if_exists=false) at /data/Server/10.6alpha/sql/sql_table.cc:10788
|
#20 0x000055a7895f81ef in Sql_cmd_alter_table::execute (this=0x62b000245c98, thd=0x62b00023e218) at /data/Server/10.6alpha/sql/sql_alter.cc:540
|
#21 0x000055a7892192ad in mysql_execute_command (thd=0x62b00023e218) at /data/Server/10.6alpha/sql/sql_parse.cc:5986
|
#22 0x000055a789225738 in mysql_parse (thd=0x62b00023e218, rawbuf=0x62b000245238 "ALTER TABLE t1 ADD UNIQUE INDEX IF NOT EXISTS `Marvão_uidx1` ( col_text(9) ), LOCK = DEFAULT, ALGORITHM = NOCOPY /* E_R Thread20 QNO 27 CON_ID 35 */", length=150, parser_state=0x46fc39e27b20) at /data/Server/10.6alpha/sql/sql_parse.cc:8018
|
By design, one of the MDL holders was the INSERT:
#0 lock_rec_create_low (c_lock=0x61900001a6a8, type_mode=258, page_id=..., page=0x72134b670000 "", heap_no=3, index=0x61600495f108, trx=0x6cdb7c397a58, holds_trx_mutex=true)
|
at /data/Server/10.6alpha/storage/innobase/lock/lock0lock.cc:1185
|
#1 0x000055a78a4133e2 in lock_rec_enqueue_waiting (c_lock=0x61900001a6a8, type_mode=2, id=..., page=0x72134b670000 "", heap_no=3, index=0x61600495f108, thr=0x62100022fac8, prdt=0x0)
|
at /data/Server/10.6alpha/storage/innobase/lock/lock0lock.cc:1280
|
#2 0x000055a78a414df7 in lock_rec_lock (impl=false, mode=2, block=0x72134ab0f728, heap_no=3, index=0x61600495f108, thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/lock/lock0lock.cc:1516
|
#3 0x000055a78a430592 in lock_sec_rec_read_check_and_lock (flags=0, block=0x72134ab0f728, rec=0x72134b670093 "444444444\200", index=0x61600495f108, offsets=0x32717e863920, mode=LOCK_S, gap_mode=0,
|
thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/lock/lock0lock.cc:5177
|
#4 0x000055a78a5c74a2 in row_ins_set_shared_rec_lock (type=0, block=0x72134ab0f728, rec=0x72134b670093 "444444444\200", index=0x61600495f108, offsets=0x32717e863920, thr=0x62100022fac8)
|
at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:1407
|
#5 0x000055a78a5ca4de in row_ins_scan_sec_index_for_duplicate (flags=0, index=0x61600495f108, entry=0x616006865408, thr=0x62100022fac8, s_latch=true, mtr=0x32717e864090, offsets_heap=0x6190004ebb80)
|
at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:2147
|
#6 0x000055a78a5cfae3 in row_ins_sec_index_entry_low (flags=0, mode=2, index=0x61600495f108, offsets_heap=0x6190004ebb80, heap=0x6190004ec080, entry=0x616006865408, trx_id=0, thr=0x62100022fac8)
|
at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3072
|
#7 0x000055a78a5d0f27 in row_ins_sec_index_entry (index=0x61600495f108, entry=0x616006865408, thr=0x62100022fac8, check_foreign=true) at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3346
|
#8 0x000055a78a5d1306 in row_ins_index_entry (index=0x61600495f108, entry=0x616006865408, thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3394
|
#9 0x000055a78a5d2334 in row_ins_index_entry_step (node=0x62100022f5f8, thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3561
|
#10 0x000055a78a5d2cf3 in row_ins (node=0x62100022f5f8, thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3707
|
#11 0x000055a78a5d3e1b in row_ins_step (thr=0x62100022fac8) at /data/Server/10.6alpha/storage/innobase/row/row0ins.cc:3853
|
#12 0x000055a78a617634 in row_insert_for_mysql (mysql_rec=0x61a0002046b8 "\350\061", prebuilt=0x62100022ed88, ins_mode=ROW_INS_NORMAL) at /data/Server/10.6alpha/storage/innobase/row/row0mysql.cc:1395
|
#13 0x000055a78a2a9482 in ha_innobase::write_row (this=0x61d000d232b8, record=0x61a0002046b8 "\350\061") at /data/Server/10.6alpha/storage/innobase/handler/ha_innodb.cc:7430
|
#14 0x000055a7899b19c8 in handler::ha_write_row (this=0x61d000d232b8, buf=0x61a0002046b8 "\350\061") at /data/Server/10.6alpha/sql/handler.cc:7162
|
#15 0x000055a78915b369 in write_record (thd=0x62b0001ab218, table=0x6190004e9d98, info=0x32717e865eb0, sink=0x0) at /data/Server/10.6alpha/sql/sql_insert.cc:2106
|
#16 0x000055a789153d49 in mysql_insert (thd=0x62b0001ab218, table_list=0x62b0001b24b8, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0)
|
at /data/Server/10.6alpha/sql/sql_insert.cc:1099
|
#17 0x000055a78920e80c in mysql_execute_command (thd=0x62b0001ab218) at /data/Server/10.6alpha/sql/sql_parse.cc:4559
|
#18 0x000055a789225738 in mysql_parse (thd=0x62b0001ab218,
|
rawbuf=0x62b0001b2238 "INSERT INTO t1 (col1,col2, col_int, col_string, col_text) VALUES ( 49, 49, 49, REPEAT(SUBSTR(CAST( 49 AS CHAR),1,1), 10), REPEAT(SUBSTR(CAST( 49 - 1 AS CHAR),1,1), @fill_amount) ) /* E_R Thread10 QNO "..., length=215, parser_state=0x32717e866b20) at /data/Server/10.6alpha/sql/sql_parse.cc:8018
|
Yes, it may feel a little strange to allow locks to be created on an uncommitted index, but that is how the logic always worked.
What would have happened before MDEV-24589 was implemented? We would have renamed the SYS_INDEXES.NAME for this uncommitted index to start with the byte 0xff, which is an invalid UTF-8 sequence, and that placeholder entry along with the index tree would have been removed later, while the table is not being used by any concurrent connection.
Discarding locks does not feel nice, but it seems that in this case we either have to do that or avoid acquiring locks on uncommitted indexes in the first place. It feels safer to break the locks when the uncommitted index pages are purged.
|