1597
MySQLERRORNotableLoggingHIGH confidence
Cannot lock a log table
Production Risk
Low — the LOCK fails; both tables remain unlocked.
What this means
A log table (general_log or slow_log) cannot be locked in the current context.
Why it happens
- 1Attempting to lock a log table alongside other tables in a LOCK TABLES statement when the combination is not permitted.
How to reproduce
trigger — this will error
trigger — this will error
LOCK TABLES mysql.general_log READ, my_table WRITE;
expected output
ERROR 1597 (HY000): You can't use locks with log tables.
Fix
Avoid mixing log table locks with other table locks
Avoid mixing log table locks with other table locks
-- Lock only the log table separately after disabling logging: SET GLOBAL general_log = 'OFF'; LOCK TABLES mysql.general_log READ; -- ... UNLOCK TABLES; SET GLOBAL general_log = 'ON';
Why this works
Log table locking must be done in isolation with the log disabled.
Sources
Official documentation ↗
MySQL 8.0 — 1597 ER_CANT_LOCK_LOG_TABLE
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev