1618
MySQLWARNINGNotableReplicationHIGH confidence

INSERT DELAYED is unsafe for statement-based replication

Production Risk

Medium — replication may produce inconsistent data on replicas.

What this means

INSERT DELAYED is unsafe for statement-based replication because the delayed insert may execute at a different time on the replica, causing ordering differences.

Why it happens
  1. 1Using INSERT DELAYED with STATEMENT binlog format.
How to reproduce
trigger — this will error
trigger — this will error
INSERT DELAYED INTO logs (msg) VALUES ('test');

expected output

Warning 1618: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT DELAYED is unsafe because the times when rows are inserted cannot be predicted.

Fix 1

Replace INSERT DELAYED with regular INSERT

Replace INSERT DELAYED with regular INSERT
INSERT INTO logs (msg) VALUES ('test');

Why this works

Regular INSERT is fully deterministic and safe for all replication modes.

Fix 2

Use ROW or MIXED binlog format

Use ROW or MIXED binlog format
SET GLOBAL binlog_format = 'ROW';

Why this works

ROW format logs actual row changes, avoiding INSERT DELAYED timing issues.

What not to do

Version notes

Sources
Official documentation ↗

MySQL 8.0 — 1618 ER_BINLOG_UNSAFE_INSERT_DELAYED

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

← All MySQL errors