[MDEV-10932] Concurrent trigger creation causes errors and corrupts the trigger Created: 2016-09-30  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Triggers
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: upstream-not-affected

Issue Links:
Relates
relates to MDEV-12029 Concurrent CREATE OR REPLACE TRIGGER ... Closed

 Description   

Very soon after startup the concurrent test reports the error

CREATE TRIGGER tr AFTER INSERT ON t2 FOR EACH ROW SET @a=1 failed: 7 Error on rename of './test/tr.TRN~' to './test/tr.TRN' (Errcode: 2 - No such file or directory)

Further attempt to deal with the trigger reveals problems. The trigger can be seen via SHOW TRIGGERS:

MySQL [test]> show triggers;
+---------+--------+-------+-----------+--------+---------+------------------------+----------------+----------------------+----------------------+--------------------+
| Trigger | Event  | Table | Statement | Timing | Created | sql_mode               | Definer        | character_set_client | collation_connection | Database Collation |
+---------+--------+-------+-----------+--------+---------+------------------------+----------------+----------------------+----------------------+--------------------+
| tr      | INSERT | t1    | SET @a=1  | AFTER  | NULL    | NO_ENGINE_SUBSTITUTION | root@127.0.0.1 | latin1               | latin1_swedish_ci    | latin1_swedish_ci  |
+---------+--------+-------+-----------+--------+---------+------------------------+----------------+----------------------+----------------------+--------------------+
1 row in set (0.00 sec)

but not via SHOW CREATE TRIGGER:

MySQL [test]> show create trigger tr;
ERROR 1360 (HY000): Trigger does not exist

It can't be dropped, either.

All that because the trigger information went out of sync.
The {[TRN}} file says the trigger belongs to t2:

$ cat tr.TRN 
TYPE=TRIGGERNAME
trigger_table=t2

but the TRG file belongs to t1:

$ ls -l *.TRG
-rw-rw---- 1 elenst elenst 255 Sep 30 19:02 t1.TRG

Grammar

query_init:
    CREATE TABLE IF NOT EXISTS t1 (i INT); CREATE TABLE t2 LIKE t1;
    
my_table:
    t1 | t2 ;
    
query:
      CREATE TRIGGER tr AFTER INSERT ON my_table FOR EACH ROW SET @a=1
    | DROP TRIGGER tr
;

Command line

perl ./runall-new.pl --grammar=1.yy --threads=2 --skip-gendata --duration=200 --queries=100M --basedir=<basedir> --vardir=<vardir>


Generated at Thu Feb 08 07:46:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.