[MDEV-31799] Unexpected ER_TRG_NO_SUCH_ROW_IN_TRG and server crash after ALTER TABLE Created: 2023-07-29  Updated: 2023-08-10  Resolved: 2023-08-10

Status: Closed
Project: MariaDB Server
Component/s: Triggers
Affects Version/s: 11.2
Fix Version/s: 11.2.1

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Dmitry Shulga
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-5816 MySQL WL#4179 - Stored programs: vali... Closed

 Description   

The failure doesn't seem to be related to online alter as such (it also happens with LOCK=SHARED etc.), but it is a regression comparing to the baseline.

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3),(4);
CREATE TABLE t2 (b INT);
CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW INSERT INTO t2 (b) VALUES (OLD.a);
 
DELETE FROM t1 LIMIT 1;
ALTER TABLE t2 FORCE;
 
DELETE FROM t1 LIMIT 1;
DELETE FROM t1 LIMIT 1;
 
# Cleanup
DROP TABLE t1, t2;

11.2 e81fa345

mysqltest: At line 9: query 'DELETE FROM t1 LIMIT 1' failed: ER_TRG_NO_SUCH_ROW_IN_TRG (1363): There is no OLD row in on INSERT trigger

Apparently the server starts thinking that the existing ON DELETE trigger is an "ON INSERT" trigger.
Without ALTER it works normally.

If we allow the test to proceed after the first failed DELETE, the second one crashes

#3  <signal handler called>
#4  0x000056542e7b5a71 in iterate_trigger_fields_and_run_func<Table_triggers_list::mark_fields_used(trg_event_type)::<lambda(Item_trigger_field*)> >(SQL_I_List<SQL_I_List<Item_trigger_field> > &, struct {...}) (trg_table_fields=..., fn=...) at /data/src/11.2/sql/sql_trigger.cc:891
#5  0x000056542e7b40b7 in Table_triggers_list::mark_fields_used (this=0x61900009f6b8, event=TRG_EVENT_DELETE) at /data/src/11.2/sql/sql_trigger.cc:2628
#6  0x000056542e8665a7 in TABLE::mark_columns_needed_for_delete (this=0x61900009ec98) at /data/src/11.2/sql/table.cc:7655
#7  0x000056542e387c65 in Sql_cmd_delete::delete_from_single_table (this=0x6290000e7230, thd=0x62c0000c0218) at /data/src/11.2/sql/sql_delete.cc:700
#8  0x000056542e392bc7 in Sql_cmd_delete::execute_inner (this=0x6290000e7230, thd=0x62c0000c0218) at /data/src/11.2/sql/sql_delete.cc:1794
#9  0x000056542e65fc54 in Sql_cmd_dml::execute (this=0x6290000e7230, thd=0x62c0000c0218) at /data/src/11.2/sql/sql_select.cc:33356
#10 0x000056542e481bb0 in mysql_execute_command (thd=0x62c0000c0218, is_called_from_prepared_stmt=false) at /data/src/11.2/sql/sql_parse.cc:4393
#11 0x000056542e49923b in mysql_parse (thd=0x62c0000c0218, rawbuf=0x6290000e6238 "DELETE FROM t1 LIMIT 1", length=22, parser_state=0x7faf329db9f0) at /data/src/11.2/sql/sql_parse.cc:7800
#12 0x000056542e471782 in dispatch_command (command=COM_QUERY, thd=0x62c0000c0218, packet=0x629000258219 "DELETE FROM t1 LIMIT 1", packet_length=22, blocking=true) at /data/src/11.2/sql/sql_parse.cc:1892
#13 0x000056542e46e4bf in do_command (thd=0x62c0000c0218, blocking=true) at /data/src/11.2/sql/sql_parse.cc:1405
#14 0x000056542e9312be in do_handle_one_connection (connect=0x608000002eb8, put_in_cache=true) at /data/src/11.2/sql/sql_connect.cc:1445
#15 0x000056542e930c7f in handle_one_connection (arg=0x608000002e38) at /data/src/11.2/sql/sql_connect.cc:1347
#16 0x000056542f54e132 in pfs_spawn_thread (arg=0x617000005b98) at /data/src/11.2/storage/perfschema/pfs.cc:2201
#17 0x00007faf3a4a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#18 0x00007faf3a5285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

The failure started happening after a set of commits for MDEV-5816 (I didn't bisect which one exactly).



 Comments   
Comment by Dmitry Shulga [ 2023-08-03 ]

The branch for review is bb-11.2-MDEV-31799

Comment by Oleksandr Byelkin [ 2023-08-09 ]

OK to push after comment fix

Generated at Thu Feb 08 10:26:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.