Comments - Unable to create after insert trigger on mariadb

8 years, 5 months ago Federico Razzoli

I tried the second version. I added a space before 'FOR EACH ROW' (maybe just a formatting problem, I don't know). It works.

Try a SHOW PROCESSLIST and look at the Status column - maybe the process is "Waiting for Metadata locks"?

 
8 years, 5 months ago Girish Dwivedi

You are right its waiting for meta data lock. How can this be resolved ?

MariaDB [(none)]> SHOW PROCESSLIST;
+----+----------+-----------------+----------+---------+------+-----------------                                ----------------+---------------------------------------------------------------                                ---------------------------------------+----------+
| Id | User     | Host            | db       | Command | Time | State                                                           | Info                                                                                                                                 | Progress |
+----+----------+-----------------+----------+---------+------+-----------------                                ----------------+---------------------------------------------------------------                                ---------------------------------------+----------+
|  8 | local741 | localhost:40651 | local741 | Sleep   |  798 |                                                                 | NULL                                                                                                                                 |    0.000 |
| 22 | root     | localhost       | local741 | Query   |    7 | Waiting for tabl                                e metadata lock | CREATE TRIGGER command_after_insert
AFTER INSERT
   ON command FOR EACH ROW

BEGIN
DECLARE vForma |    0.000 |
| 23 | root     | localhost       | NULL     | Query   |    0 | NULL                                                            | SHOW PROCESSLIST                                                                                                                     |    0.000 |
+----+----------+-----------------+----------+---------+------+-----------------                                ----------------+---------------------------------------------------------------                                ---------------------------------------+----------+
3 rows in set (0.00 sec)
 
8 years, 5 months ago Federico Razzoli

Ideally, the process that's holding the lock should COMMIT the current transaction. If you can't achieve this, just kill the process:

KILL 8

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.