CREATE DATABASE IF NOT EXISTS test1;
USE test1;

CREATE TABLE `a` (
  `a_id` int(10) unsigned
) ENGINE=InnoDB;

CREATE TRIGGER a_audit_after_insert AFTER INSERT ON a FOR EACH ROW
INSERT INTO a_log (a_id) VALUES (NEW.a_id);

# !!! removing this AFTER UPDATE trigger makes the error go away -- even though we're not updating the a table
CREATE TRIGGER a_audit_after_update AFTER UPDATE ON a FOR EACH ROW
INSERT INTO a_log (a_id) VALUES (NEW.a_id);

DROP TABLE IF EXISTS `a_log`;
CREATE TABLE `a_log` (
  `a_id` int(10) unsigned
) ENGINE=InnoDB;

create view view_referencing_a_log as select 1 from a_log; # !!! removing the view makes the error go away

LOCK TABLES a WRITE; # !!! write-locking `a_log` as well makes the error go away (as shown below), as does removing the lock entirely
#LOCK TABLES a WRITE, a_log WRITE;

INSERT INTO a (a_id) VALUES (1);

UNLOCK TABLES;
