The test case appears to be deterministic, the concurrency here is on the transaction level. I suppose it can be further simplified, but it's not easy to guess blindly what can be replaced with what, so I'll leave it as it is for now, hopefully it will be clearer after the analysis.
--source include/have_innodb.inc
CREATETABLE t1 (id INTPRIMARYKEY, col_varchar VARCHAR(8)) ENGINE=InnoDB;
INSERTINTO t1 (id) VALUES (1),(2);
CREATETABLE t2 (id INT, f INT, s DATE, e DATE, PERIOD FOR p(s,e), PRIMARYKEY(id, p WITHOUT OVERLAPS)) ENGINE=InnoDB;
250126 21:12:56 [ERROR] /share8t/bld/10.6-asan/sql/mariadbd got signal 6 ;
#9 0x00007fee4cc53eb2 in __GI___assert_fail (assertion=0x55ae9e0c92a0 "not_autocommit || trx->n_mysql_tables_in_use || (trx->lock.trx_locks).count == 0", file=0x55ae9e0b2be0 "/data/bld/10.6-asan/storage/innobase/handler/ha_innodb.cc", line=16341, function=0x55ae9e0c90e0 "virtual int ha_innobase::external_lock(THD*, int)") at ./assert/assert.c:101
#10 0x000055ae9c78fe97 in ha_innobase::external_lock (this=0x62d0000a1760, thd=0x62b0000bd218, lock_type=0) at /data/bld/10.6-asan/storage/innobase/handler/ha_innodb.cc:16341
#11 0x000055ae9bd01e12 in handler::ha_external_lock (this=0x62d0000a1760, thd=0x62b0000bd218, lock_type=0) at /data/bld/10.6-asan/sql/handler.cc:7226
#12 0x000055ae9bcddd10 in handler::create_lookup_handler (this=0x6250002a3148) at /data/bld/10.6-asan/sql/handler.cc:3326
#13 0x000055ae9bd06fb4 in handler::prepare_for_insert (this=0x6250002a3148, do_create=true) at /data/bld/10.6-asan/sql/handler.cc:7689
#14 0x000055ae9b77872a in mysql_update (thd=0x62b0000bd218, table_list=0x62d0000a0578, fields=..., values=..., conds=0x0, order_num=1, order=0x62d0000a0ff0, limit=1, ignore=false, found_return=0x7fee3e0e3f00, updated_return=0x7fee3e0e3f20) at /data/bld/10.6-asan/sql/sql_update.cc:1024
#15 0x000055ae9b43df7d in mysql_execute_command (thd=0x62b0000bd218, is_called_from_prepared_stmt=false) at /data/bld/10.6-asan/sql/sql_parse.cc:4477
#16 0x000055ae9b457d60 in mysql_parse (thd=0x62b0000bd218, rawbuf=0x62d0000a0438 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", length=42, parser_state=0x7fee3e0e4a90) at /data/bld/10.6-asan/sql/sql_parse.cc:8208
#17 0x000055ae9b42d123 in dispatch_command (command=COM_QUERY, thd=0x62b0000bd218, packet=0x629000276219 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", packet_length=42, blocking=true) at /data/bld/10.6-asan/sql/sql_parse.cc:1908
#18 0x000055ae9b429e57 in do_command (thd=0x62b0000bd218, blocking=true) at /data/bld/10.6-asan/sql/sql_parse.cc:1421
#19 0x000055ae9b8ac8c1 in do_handle_one_connection (connect=0x608000018ab8, put_in_cache=true) at /data/bld/10.6-asan/sql/sql_connect.cc:1386
#20 0x000055ae9b8ac420 in handle_one_connection (arg=0x608000018a38) at /data/bld/10.6-asan/sql/sql_connect.cc:1298
#21 0x000055ae9c525966 in pfs_spawn_thread (arg=0x617000007e98) at /data/bld/10.6-asan/storage/perfschema/pfs.cc:2201
#22 0x00007fee4cca81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#23 0x00007fee4cd2885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#5 0x0000562fe743d2b1 in ha_innobase::external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16314
#6 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#7 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c88016c88, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#8 0x0000562fe70ac476 in handler::ha_reset (this=0x7f9c8805fee8) at /mariadb/10.6m/sql/handler.cc:7291
#9 0x0000562fe6c5f5b2 in close_thread_table (thd=0x7f9c88001168, table_ptr=0x7f9c88001260) at /mariadb/10.6m/sql/sql_base.cc:1028
#10 0x0000562fe6c5f15d in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:968
#11 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#12 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
This is duplicating an earlier call during the execution of the same statement:
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#0 ha_innobase::external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16163
#1 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#2 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c8805fee8, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#3 0x0000562fe71fcebc in unlock_external (thd=0x7f9c88001168, table=0x7f9c88015558, count=0x1) at /mariadb/10.6m/sql/lock.cc:730
#4 0x0000562fe71fc39f in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538, free_lock=0x0) at /mariadb/10.6m/sql/lock.cc:435
#5 0x0000562fe71fc30d in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538) at /mariadb/10.6m/sql/lock.cc:418
#6 0x0000562fe6c5f12f in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:960
#7 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#8 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
If I revert the MDEV-24035 change and add the corresponding debug assertion, it will not fail. I see that in that case, the two calls with F_UNLCK are preceded by one call with F_WRLCK and F_RDLCK each, in that order. I suspect that one of the preceding calls will work differently in the presence of the MDEV-24035 change.
Marko Mäkelä
added a comment - The following assertion would fail, indicating an API violation:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 4dd7a9405dd..aeccf3fec17 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -16311,6 +16311,7 @@ ha_innobase::external_lock(
case F_UNLCK:
DEBUG_SYNC_C("ha_innobase_end_statement");
m_mysql_has_locked = false;
+ ut_ad(trx->n_mysql_tables_in_use);
if (--trx->n_mysql_tables_in_use) {
break;
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#5 0x0000562fe743d2b1 in ha_innobase::external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16314
#6 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#7 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c88016c88, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#8 0x0000562fe70ac476 in handler::ha_reset (this=0x7f9c8805fee8) at /mariadb/10.6m/sql/handler.cc:7291
#9 0x0000562fe6c5f5b2 in close_thread_table (thd=0x7f9c88001168, table_ptr=0x7f9c88001260) at /mariadb/10.6m/sql/sql_base.cc:1028
#10 0x0000562fe6c5f15d in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:968
#11 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#12 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
This is duplicating an earlier call during the execution of the same statement:
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#0 ha_innobase::external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16163
#1 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#2 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c8805fee8, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#3 0x0000562fe71fcebc in unlock_external (thd=0x7f9c88001168, table=0x7f9c88015558, count=0x1) at /mariadb/10.6m/sql/lock.cc:730
#4 0x0000562fe71fc39f in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538, free_lock=0x0) at /mariadb/10.6m/sql/lock.cc:435
#5 0x0000562fe71fc30d in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538) at /mariadb/10.6m/sql/lock.cc:418
#6 0x0000562fe6c5f12f in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:960
#7 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#8 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
If I revert the MDEV-24035 change and add the corresponding debug assertion, it will not fail. I see that in that case, the two calls with F_UNLCK are preceded by one call with F_WRLCK and F_RDLCK each, in that order. I suspect that one of the preceding calls will work differently in the presence of the MDEV-24035 change.
It turns out that there are two bugs in mysql_delete(), which is handling DELETE statements. The transaction had been aborted here:
10.6 d77b9a4925c971364707d435028add41e8015173
#0 innodb_transaction_abort (thd=0x7ef9ec0011d8, all=0x1, err=DB_DEADLOCK) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:2155
#1 0x00006012ca52514e in convert_error_code_to_mysql (error=DB_DEADLOCK, flags=<optimized out>, thd=0x7ef9ec0011d8) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:2227
#2 0x00006012ca52893a in ha_innobase::index_read (this=0x7ef9ec1c2ca8, buf=0x7ef9ec1c34a8 "\377", key_ptr=key_ptr@entry=0x0, key_len=key_len@entry=0x0, find_flag=find_flag@entry=HA_READ_AFTER_KEY)
at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9145
#3 0x00006012ca528fdc in ha_innobase::index_first (this=0x7ef9ec0011d8, buf=0x6012cd43f078 "\f") at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9471
#4 ha_innobase::rnd_next (this=0x7ef9ec0011d8, buf=0x6012cd43f078 "\f") at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9563
#5 0x00006012ca26886b in handler::ha_rnd_next (this=0x7ef9ec1c2ca8, buf=0x7ef9ec1c34a8 "\377") at /home/marko/10.6/sql/handler.cc:3533
#6 0x00006012ca3d8694 in rr_sequential (info=0x7efa1ee7c768) at /home/marko/10.6/sql/records.cc:519
#7 0x00006012ca3f2993 in READ_RECORD::read_record (this=0x7efa1ee7c768) at /home/marko/10.6/sql/records.h:81
#9 0x00006012c9ff9f5a in mysql_execute_command (thd=thd@entry=0x7ef9ec0011d8, is_called_from_prepared_stmt=<optimized out>) at /home/marko/10.6/sql/sql_parse.cc:4924
#10 0x00006012c9ff1220 in mysql_parse (thd=thd@entry=0x7ef9ec0011d8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7efa1ee7d510) at /home/marko/10.6/sql/sql_parse.cc:8208
#11 0x00006012c9fef8b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7ef9ec0011d8,
packet=packet@entry=0x7ef9ec00c529 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", packet_length=packet_length@entry=0x41, blocking=0x1) at /home/marko/10.6/sql/sql_parse.cc:1908
Because of this, the call to ha_innobase::external_lock(F_RDLCK) will return an error, which the caller is ignoring (again):
10.6 d77b9a4925c971364707d435028add41e8015173
#0 ha_innobase::external_lock (this=0x7ef9ec0187e8, thd=0x7ef9ec0011d8, lock_type=0x0) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:16165
#1 0x00006012ca268131 in handler::ha_external_lock (this=0x7ef9ec0187e8, thd=0x7ef9ec0011d8, lock_type=lock_type@entry=0x0) at /home/marko/10.6/sql/handler.cc:7226
#2 0x00006012ca272238 in handler::create_lookup_handler (this=0x7ef9ec1c2ca8) at /home/marko/10.6/sql/handler.cc:3326
#3 handler::prepare_for_insert (this=0x7ef9ec1c2ca8, do_create=<optimized out>) at /home/marko/10.6/sql/handler.cc:7689
#4 0x00006012ca3f2b1e in mysql_delete (thd=thd@entry=0x7ef9ec0011d8, table_list=0x7ef9ec0166c0, conds=0x7ef9ec017a90, order_list=order_list@entry=0x7ef9ec005ee0, limit=0xffffffffffffffff, options=0x0,
result=<optimized out>) at /home/marko/10.6/sql/sql_delete.cc:823
#5 0x00006012c9ff9f5a in mysql_execute_command (thd=thd@entry=0x7ef9ec0011d8, is_called_from_prepared_stmt=<optimized out>) at /home/marko/10.6/sql/sql_parse.cc:4924
#6 0x00006012c9ff1220 in mysql_parse (thd=thd@entry=0x7ef9ec0011d8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7efa1ee7d510) at /home/marko/10.6/sql/sql_parse.cc:8208
#7 0x00006012c9fef8b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7ef9ec0011d8,
packet=packet@entry=0x7ef9ec00c529 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", packet_length=packet_length@entry=0x41, blocking=0x1) at /home/marko/10.6/sql/sql_parse.cc:1908
This error is being ignored here:
mysql_delete()
822
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
823
table->file->prepare_for_insert(1);
Like I have pointed out in MDEV-24812 two years ago, it would be helpful to declare this kind of functions with the attribute warn_unused_result, so that errors cannot be ignored. In any case, already the first error was being ignored in the same function. The following patch would fix that:
Marko Mäkelä
added a comment - It turns out that there are two bugs in mysql_delete() , which is handling DELETE statements. The transaction had been aborted here:
10.6 d77b9a4925c971364707d435028add41e8015173
#0 innodb_transaction_abort (thd=0x7ef9ec0011d8, all=0x1, err=DB_DEADLOCK) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:2155
#1 0x00006012ca52514e in convert_error_code_to_mysql (error=DB_DEADLOCK, flags=<optimized out>, thd=0x7ef9ec0011d8) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:2227
#2 0x00006012ca52893a in ha_innobase::index_read (this=0x7ef9ec1c2ca8, buf=0x7ef9ec1c34a8 "\377", key_ptr=key_ptr@entry=0x0, key_len=key_len@entry=0x0, find_flag=find_flag@entry=HA_READ_AFTER_KEY)
at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9145
#3 0x00006012ca528fdc in ha_innobase::index_first (this=0x7ef9ec0011d8, buf=0x6012cd43f078 "\f") at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9471
#4 ha_innobase::rnd_next (this=0x7ef9ec0011d8, buf=0x6012cd43f078 "\f") at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:9563
#5 0x00006012ca26886b in handler::ha_rnd_next (this=0x7ef9ec1c2ca8, buf=0x7ef9ec1c34a8 "\377") at /home/marko/10.6/sql/handler.cc:3533
#6 0x00006012ca3d8694 in rr_sequential (info=0x7efa1ee7c768) at /home/marko/10.6/sql/records.cc:519
#7 0x00006012ca3f2993 in READ_RECORD::read_record (this=0x7efa1ee7c768) at /home/marko/10.6/sql/records.h:81
#8 mysql_delete (thd=thd@entry=0x7ef9ec0011d8, table_list=0x7ef9ec0166c0, conds=0x7ef9ec017a90, order_list=order_list@entry=0x7ef9ec005ee0, limit=0xffffffffffffffff, options=0x0, result=<optimized out>)
at /home/marko/10.6/sql/sql_delete.cc:776
#9 0x00006012c9ff9f5a in mysql_execute_command (thd=thd@entry=0x7ef9ec0011d8, is_called_from_prepared_stmt=<optimized out>) at /home/marko/10.6/sql/sql_parse.cc:4924
#10 0x00006012c9ff1220 in mysql_parse (thd=thd@entry=0x7ef9ec0011d8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7efa1ee7d510) at /home/marko/10.6/sql/sql_parse.cc:8208
#11 0x00006012c9fef8b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7ef9ec0011d8,
packet=packet@entry=0x7ef9ec00c529 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", packet_length=packet_length@entry=0x41, blocking=0x1) at /home/marko/10.6/sql/sql_parse.cc:1908
Because of this, the call to ha_innobase::external_lock(F_RDLCK) will return an error, which the caller is ignoring (again):
10.6 d77b9a4925c971364707d435028add41e8015173
#0 ha_innobase::external_lock (this=0x7ef9ec0187e8, thd=0x7ef9ec0011d8, lock_type=0x0) at /home/marko/10.6/storage/innobase/handler/ha_innodb.cc:16165
#1 0x00006012ca268131 in handler::ha_external_lock (this=0x7ef9ec0187e8, thd=0x7ef9ec0011d8, lock_type=lock_type@entry=0x0) at /home/marko/10.6/sql/handler.cc:7226
#2 0x00006012ca272238 in handler::create_lookup_handler (this=0x7ef9ec1c2ca8) at /home/marko/10.6/sql/handler.cc:3326
#3 handler::prepare_for_insert (this=0x7ef9ec1c2ca8, do_create=<optimized out>) at /home/marko/10.6/sql/handler.cc:7689
#4 0x00006012ca3f2b1e in mysql_delete (thd=thd@entry=0x7ef9ec0011d8, table_list=0x7ef9ec0166c0, conds=0x7ef9ec017a90, order_list=order_list@entry=0x7ef9ec005ee0, limit=0xffffffffffffffff, options=0x0,
result=<optimized out>) at /home/marko/10.6/sql/sql_delete.cc:823
#5 0x00006012c9ff9f5a in mysql_execute_command (thd=thd@entry=0x7ef9ec0011d8, is_called_from_prepared_stmt=<optimized out>) at /home/marko/10.6/sql/sql_parse.cc:4924
#6 0x00006012c9ff1220 in mysql_parse (thd=thd@entry=0x7ef9ec0011d8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7efa1ee7d510) at /home/marko/10.6/sql/sql_parse.cc:8208
#7 0x00006012c9fef8b0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7ef9ec0011d8,
packet=packet@entry=0x7ef9ec00c529 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", packet_length=packet_length@entry=0x41, blocking=0x1) at /home/marko/10.6/sql/sql_parse.cc:1908
This error is being ignored here:
mysql_delete()
822
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
823
table->file->prepare_for_insert(1);
Like I have pointed out in MDEV-24812 two years ago, it would be helpful to declare this kind of functions with the attribute warn_unused_result , so that errors cannot be ignored. In any case, already the first error was being ignored in the same function. The following patch would fix that:
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 2e77e32aed9..702f9d2d1ac 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -790,6 +790,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
}
end_read_record(&info);
+ if (error)
+ goto terminate_delete;
if (unlikely(deltempfile->get(table)) ||
unlikely(table->file->ha_index_or_rnd_end()) ||
unlikely(init_read_record(&info, thd, table, 0, &deltempfile->sort, 0,
In addition to this, I would propose adding a non-debug assertion in order to prevent serious corruption:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 4dd7a9405dd..8dafc0e606e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -16311,6 +16311,7 @@ ha_innobase::external_lock(
case F_UNLCK:
DEBUG_SYNC_C("ha_innobase_end_statement");
m_mysql_has_locked = false;
+ ut_a(trx->n_mysql_tables_in_use);
if (--trx->n_mysql_tables_in_use) {
break;
Also the return value of table->file->prepare_for_insert() must be checked in mysql_delete() , possibly with something like the following:
@@ -820,7 +822,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
&& table->file->has_transactions();
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
- table->file->prepare_for_insert(1);
+ {
+ error= table->file->prepare_for_insert(1);
+ if (error)
+ terminate_delete;
+ }
DBUG_ASSERT(table->file->inited != handler::NONE);
THD_STAGE_INFO(thd, stage_updating);
Interesting 2 things:
1) we never check result of handler::prepare_for_insert() (not in even one case)
2) failure of handler::prepare_for_insert() do not set an error (if add process of this error a lot of tests fails (mostly innodb & replication)
So above is not just question of reaction on error result in one chosen place.
It look like it fails inside that handler::prepare_for_insert() call
#4 0x00007ffff7816177 in __assert_fail () from /usr/lib/libc.so.6
#5 0x000055555683c135 in ha_innobase::external_lock (this=0x7fffc40168f0, thd=0x7fffc4000dc8, lock_type=0) at /home/sanja/maria/git/10.6/storage/innobase/handler/ha_innodb.cc:16341
#6 0x0000555556388b8a in handler::ha_external_lock (this=0x7fffc40168f0, thd=0x7fffc4000dc8, lock_type=0) at /home/sanja/maria/git/10.6/sql/handler.cc:7226
#7 0x000055555637af38 in handler::create_lookup_handler (this=0x7fffb8023d48) at /home/sanja/maria/git/10.6/sql/handler.cc:3326
#8 0x000055555638a9e2 in handler::prepare_for_insert (this=0x7fffb8023d48, do_create=true) at /home/sanja/maria/git/10.6/sql/handler.cc:7689
#9 0x00005555560fa404 in mysql_update (thd=0x7fffc4000dc8, table_list=0x7fffc40157e8, fields=..., values=..., conds=0x0, order_num=1, order=0x7fffc4016200, limit=1, ignore=false, found_return=0x7ffff00adc70, updated_return=0x7ffff00adde0) at /home/sanja/maria/git/10.6/sql/sql_update.cc:1024
#10 0x0000555555faa314 in mysql_execute_command (thd=0x7fffc4000dc8, is_called_from_prepared_stmt=false) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:4477
#11 0x0000555555fb6f49 in mysql_parse (thd=0x7fffc4000dc8, rawbuf=0x7fffc40156e0 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", length=42, parser_state=0x7ffff00ae270) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:8208
#12 0x0000555555fa2100 in dispatch_command (command=COM_QUERY, thd=0x7fffc4000dc8, packet=0x7fffc400baf9 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", packet_length=42, blocking=true) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:1908
#13 0x0000555555fa09d5 in do_command (thd=0x7fffc4000dc8, blocking=true) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:1421
#14 0x000055555617c6f9 in do_handle_one_connection (connect=0x555558d3fd58, put_in_cache=true) at /home/sanja/maria/git/10.6/sql/sql_connect.cc:1386
#15 0x000055555617c47f in handle_one_connection (arg=0x555558d012e8) at /home/sanja/maria/git/10.6/sql/sql_connect.cc:1298
And adding check of result of it can not help
Oleksandr Byelkin
added a comment - It look like it fails inside that handler::prepare_for_insert() call
#4 0x00007ffff7816177 in __assert_fail () from /usr/lib/libc.so.6
#5 0x000055555683c135 in ha_innobase::external_lock (this=0x7fffc40168f0, thd=0x7fffc4000dc8, lock_type=0) at /home/sanja/maria/git/10.6/storage/innobase/handler/ha_innodb.cc:16341
#6 0x0000555556388b8a in handler::ha_external_lock (this=0x7fffc40168f0, thd=0x7fffc4000dc8, lock_type=0) at /home/sanja/maria/git/10.6/sql/handler.cc:7226
#7 0x000055555637af38 in handler::create_lookup_handler (this=0x7fffb8023d48) at /home/sanja/maria/git/10.6/sql/handler.cc:3326
#8 0x000055555638a9e2 in handler::prepare_for_insert (this=0x7fffb8023d48, do_create=true) at /home/sanja/maria/git/10.6/sql/handler.cc:7689
#9 0x00005555560fa404 in mysql_update (thd=0x7fffc4000dc8, table_list=0x7fffc40157e8, fields=..., values=..., conds=0x0, order_num=1, order=0x7fffc4016200, limit=1, ignore=false, found_return=0x7ffff00adc70, updated_return=0x7ffff00adde0) at /home/sanja/maria/git/10.6/sql/sql_update.cc:1024
#10 0x0000555555faa314 in mysql_execute_command (thd=0x7fffc4000dc8, is_called_from_prepared_stmt=false) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:4477
#11 0x0000555555fb6f49 in mysql_parse (thd=0x7fffc4000dc8, rawbuf=0x7fffc40156e0 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", length=42, parser_state=0x7ffff00ae270) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:8208
#12 0x0000555555fa2100 in dispatch_command (command=COM_QUERY, thd=0x7fffc4000dc8, packet=0x7fffc400baf9 "UPDATE t3 SET f = 'foo' ORDER BY f LIMIT 1", packet_length=42, blocking=true) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:1908
#13 0x0000555555fa09d5 in do_command (thd=0x7fffc4000dc8, blocking=true) at /home/sanja/maria/git/10.6/sql/sql_parse.cc:1421
#14 0x000055555617c6f9 in do_handle_one_connection (connect=0x555558d3fd58, put_in_cache=true) at /home/sanja/maria/git/10.6/sql/sql_connect.cc:1386
#15 0x000055555617c47f in handle_one_connection (arg=0x555558d012e8) at /home/sanja/maria/git/10.6/sql/sql_connect.cc:1298
And adding check of result of it can not help
OK, claims by marko that the problem is in unchecked handler call result appeared to be a bit misleading, something other is wrong before the call.
Oleksandr Byelkin
added a comment - OK, claims by marko that the problem is in unchecked handler call result appeared to be a bit misleading, something other is wrong before the call.
MDEV-35944 Assertion failures in ha_innobase::external_lock or in trx_t::free
Process errors of read_record()
Oleksandr Byelkin
added a comment -
commit 522364c6cfd416d874d888d2e75f454b7da0b930 (HEAD -> bb-10.6-MDEV-35944, origin/bb-10.6-MDEV-35944)
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Mon Jan 27 15:21:15 2025 +0100
MDEV-35944 Assertion failures in ha_innobase::external_lock or in trx_t::free
Process errors of read_record()
This is wrong, as error is set to -1 oif the read loop is sucessfull.
If there was an error, thd->is_error() is set.
Better to do:
+ if (thd->is_error())
+ goto terminate_delete;
However before doing that, the cleanups on the following lines needs to be done!
Michael Widenius
added a comment - + if (error)
+ goto terminate_delete;
This is wrong, as error is set to -1 oif the read loop is sucessfull.
If there was an error, thd->is_error() is set.
Better to do:
+ if (thd->is_error())
+ goto terminate_delete;
However before doing that, the cleanups on the following lines needs to be done!
I have now created a 'final' patch for the first part (checking error after read loop) and created a separate patch for this.
Now working on another patch that changes prepare_for_insert() to generate errors for failures and also adding checking of the return value for prepare_for_insert() everywhere.
Michael Widenius
added a comment - I have now created a 'final' patch for the first part (checking error after read loop) and created a separate patch for this.
Now working on another patch that changes prepare_for_insert() to generate errors for failures and also adding checking of the return value for prepare_for_insert() everywhere.
I hope that the final version will include the assertion change that I suggested adding to ha_innobase::external_lock(), so that any further cases like this will fail in a more obvious way.
Marko Mäkelä
added a comment - I hope that the final version will include the assertion change that I suggested adding to ha_innobase::external_lock() , so that any further cases like this will fail in a more obvious way.
People
Sergei Golubchik
Elena Stepanova
Votes:
0Vote for this issue
Watchers:
6Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1268.5999994277954,"ttfb":344.5,"pageVisibility":"visible","entityId":132561,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"5155de5c-4e6e-46d7-b4e0-6cb98ac98094","navigationType":0,"readyForUser":1386.6999998092651,"redirectCount":0,"resourceLoadedEnd":1586.6999998092651,"resourceLoadedStart":352.8999996185303,"resourceTiming":[{"duration":351.1000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":352.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":352.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":704,"responseStart":0,"secureConnectionStart":0},{"duration":351.1000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":353.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":353.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":704.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":361.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":353.30000019073486,"connectEnd":353.30000019073486,"connectStart":353.30000019073486,"domainLookupEnd":353.30000019073486,"domainLookupStart":353.30000019073486,"fetchStart":353.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":353.30000019073486,"responseEnd":714.6999998092651,"responseStart":714.6999998092651,"secureConnectionStart":353.30000019073486},{"duration":419.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":353.5999994277954,"connectEnd":353.5999994277954,"connectStart":353.5999994277954,"domainLookupEnd":353.5999994277954,"domainLookupStart":353.5999994277954,"fetchStart":353.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":353.5999994277954,"responseEnd":773.3999996185303,"responseStart":773.3999996185303,"secureConnectionStart":353.5999994277954},{"duration":423.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":353.80000019073486,"connectEnd":353.80000019073486,"connectStart":353.80000019073486,"domainLookupEnd":353.80000019073486,"domainLookupStart":353.80000019073486,"fetchStart":353.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":353.80000019073486,"responseEnd":777.3000001907349,"responseStart":777.1999998092651,"secureConnectionStart":353.80000019073486},{"duration":423.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":353.8999996185303,"connectEnd":353.8999996185303,"connectStart":353.8999996185303,"domainLookupEnd":353.8999996185303,"domainLookupStart":353.8999996185303,"fetchStart":353.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":353.8999996185303,"responseEnd":777.6999998092651,"responseStart":777.6999998092651,"secureConnectionStart":353.8999996185303},{"duration":423.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":354.0999994277954,"connectEnd":354.0999994277954,"connectStart":354.0999994277954,"domainLookupEnd":354.0999994277954,"domainLookupStart":354.0999994277954,"fetchStart":354.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":354.0999994277954,"responseEnd":778,"responseStart":778,"secureConnectionStart":354.0999994277954},{"duration":515.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":354.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":354.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":870.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":423.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":354.5,"connectEnd":354.5,"connectStart":354.5,"domainLookupEnd":354.5,"domainLookupStart":354.5,"fetchStart":354.5,"redirectEnd":0,"redirectStart":0,"requestStart":354.5,"responseEnd":778.3999996185303,"responseStart":778.3999996185303,"secureConnectionStart":354.5},{"duration":515.6999998092651,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":354.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":354.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":870.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":424.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":354.80000019073486,"connectEnd":354.80000019073486,"connectStart":354.80000019073486,"domainLookupEnd":354.80000019073486,"domainLookupStart":354.80000019073486,"fetchStart":354.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":354.80000019073486,"responseEnd":779,"responseStart":779,"secureConnectionStart":354.80000019073486},{"duration":739.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":364.3999996185303,"connectEnd":364.3999996185303,"connectStart":364.3999996185303,"domainLookupEnd":364.3999996185303,"domainLookupStart":364.3999996185303,"fetchStart":364.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":364.3999996185303,"responseEnd":1104,"responseStart":1104,"secureConnectionStart":364.3999996185303},{"duration":1205.5999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":376.5,"connectEnd":376.5,"connectStart":376.5,"domainLookupEnd":376.5,"domainLookupStart":376.5,"fetchStart":376.5,"redirectEnd":0,"redirectStart":0,"requestStart":376.5,"responseEnd":1582.0999994277954,"responseStart":1582,"secureConnectionStart":376.5},{"duration":201.10000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":903.3999996185303,"connectEnd":903.3999996185303,"connectStart":903.3999996185303,"domainLookupEnd":903.3999996185303,"domainLookupStart":903.3999996185303,"fetchStart":903.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":903.3999996185303,"responseEnd":1104.5,"responseStart":1104.5,"secureConnectionStart":903.3999996185303},{"duration":368.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1218.5999994277954,"connectEnd":1218.5999994277954,"connectStart":1218.5999994277954,"domainLookupEnd":1218.5999994277954,"domainLookupStart":1218.5999994277954,"fetchStart":1218.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":1218.5999994277954,"responseEnd":1586.6999998092651,"responseStart":1586.6999998092651,"secureConnectionStart":1218.5999994277954}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":15,"responseStart":344,"responseEnd":376,"domLoading":351,"domInteractive":1649,"domContentLoadedEventStart":1649,"domContentLoadedEventEnd":1715,"domComplete":2208,"loadEventStart":2208,"loadEventEnd":2209,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1589.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1590.5999994277954},{"name":"bigPipe.activity-panel-pipe-id.start","time":1590.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1597.5},{"name":"activityTabFullyLoaded","time":1739.8000001907349}],"measures":[],"correlationId":"c52c62698e73be","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":237,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The following assertion would fail, indicating an API violation:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 4dd7a9405dd..aeccf3fec17 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -16311,6 +16311,7 @@ ha_innobase::external_lock(
case F_UNLCK:
DEBUG_SYNC_C("ha_innobase_end_statement");
m_mysql_has_locked = false;
+ ut_ad(trx->n_mysql_tables_in_use);
if (--trx->n_mysql_tables_in_use) {
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#5 0x0000562fe743d2b1 in ha_innobase::external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16314
#6 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c88016c88, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#7 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c88016c88, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#8 0x0000562fe70ac476 in handler::ha_reset (this=0x7f9c8805fee8) at /mariadb/10.6m/sql/handler.cc:7291
#9 0x0000562fe6c5f5b2 in close_thread_table (thd=0x7f9c88001168, table_ptr=0x7f9c88001260) at /mariadb/10.6m/sql/sql_base.cc:1028
#10 0x0000562fe6c5f15d in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:968
#11 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#12 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
This is duplicating an earlier call during the execution of the same statement:
10.6 d77b9a4925c971364707d435028add41e8015173 with the patch
#0 ha_innobase::external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/storage/innobase/handler/ha_innodb.cc:16163
#1 0x0000562fe70ac05e in handler::ha_external_lock (this=0x7f9c8805fee8, thd=0x7f9c88001168, lock_type=0x2) at /mariadb/10.6m/sql/handler.cc:7226
#2 0x0000562fe6e1b4c0 in handler::ha_external_unlock (this=0x7f9c8805fee8, thd=0x7f9c88001168) at /mariadb/10.6m/sql/handler.h:3562
#3 0x0000562fe71fcebc in unlock_external (thd=0x7f9c88001168, table=0x7f9c88015558, count=0x1) at /mariadb/10.6m/sql/lock.cc:730
#4 0x0000562fe71fc39f in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538, free_lock=0x0) at /mariadb/10.6m/sql/lock.cc:435
#5 0x0000562fe71fc30d in mysql_unlock_tables (thd=0x7f9c88001168, sql_lock=0x7f9c88015538) at /mariadb/10.6m/sql/lock.cc:418
#6 0x0000562fe6c5f12f in close_thread_tables (thd=0x7f9c88001168) at /mariadb/10.6m/sql/sql_base.cc:960
#7 0x0000562fe6d0df17 in mysql_execute_command (thd=0x7f9c88001168, is_called_from_prepared_stmt=0x0) at /mariadb/10.6m/sql/sql_parse.cc:6230
#8 0x0000562fe6d13712 in mysql_parse (thd=0x7f9c88001168, rawbuf=0x7f9c88014a30 "DELETE FROM t2 FOR PORTION OF p FROM '2000-01-01' TO '2000-01-02'", length=0x41, parser_state=0x7f9cb44cd3f0)
at /mariadb/10.6m/sql/sql_parse.cc:8208
If I revert the
MDEV-24035change and add the corresponding debug assertion, it will not fail. I see that in that case, the two calls with F_UNLCK are preceded by one call with F_WRLCK and F_RDLCK each, in that order. I suspect that one of the preceding calls will work differently in the presence of theMDEV-24035change.