1927
MySQLERRORNotableLockingHIGH confidence

Cannot lock log table

Production Risk

Low — lock statement is rejected; no data affected.

What this means

MySQL refused to lock a log table because log tables cannot be locked alongside other tables in the same LOCK TABLES statement.

Why it happens
  1. 1LOCK TABLES t1 READ, mysql.general_log READ — mixing log tables with regular tables.
How to reproduce
trigger — this will error
trigger — this will error
LOCK TABLES orders READ, mysql.general_log READ;

expected output

ERROR 1927 (HY000): Cannot lock log table.

Fix

Do not mix log tables with other tables in LOCK TABLES

Do not mix log tables with other tables in LOCK TABLES
-- Query general_log separately without locking
SELECT * FROM mysql.general_log WHERE event_time > NOW() - INTERVAL 1 HOUR;

Why this works

Log tables must be queried without explicit table locks.

Sources
Official documentation ↗

MySQL 8.0 — 1927 ER_CANT_LOCK_LOG_TABLE2

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors