Common SQL Errors

MySQL Error 3002: ER_INCONSISTENT_ERROR - How to Fix Master/Slave Replication Mismatches

Galaxy Team
August 8, 2025

MySQL raises ER_INCONSISTENT_ERROR (3002) when a statement produces different errors on the primary (master) and replica (slave), breaking binary log consistency and halting replication.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL Error 3002 ER_INCONSISTENT_ERROR?

ER_INCONSISTENT_ERROR (3002) means a query failed differently on master and slave, stopping replication. Align schemas, skip the inconsistent event, and restart replication to fix the issue.

Error Highlights

Typical Error Message

ER_INCONSISTENT_ERROR

Error Type

Replication Error

Language

MySQL

Symbol

on master: message (format)='%s' error code=%d; Error on slave:actual message='%s', error code=%d. Default database:'%s'. Query:'%s'

Error Code

3002

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 3002 ER_INCONSISTENT_ERROR?

MySQL throws ER_INCONSISTENT_ERROR (code 3002, SQLSTATE HY000) when a binary logged statement fails with one error on the primary server but triggers a different error on the replica. The mismatch breaks deterministic replication guarantees, so MySQL stops the SQL thread to prevent data drift.

The error text lists both messages and error codes, the default database, and the failing query. Because the event already executed on the master, ignoring it on the replica can create divergence, so you must diagnose quickly.

What Causes This Error?

Most cases trace back to schema or data differences between master and replica. If a column exists on one server but not the other, an UPDATE may succeed on the master yet fail with ER_BAD_FIELD_ERROR on the replica, triggering ER_INCONSISTENT_ERROR.

Other triggers include non-deterministic functions, unsafe SQL modes, executed triggers that differ between nodes, or a replication delay that let DDL run in a different order. Hardware faults and corrupted relay logs can also produce mismatched errors.

How to Fix MySQL Error 3002

First, stop the SQL thread to freeze the replica state. Inspect the failing query and compare schemas and data between master and replica. Align them, then either skip the bad event or rebuild replication.

Use CHANGE MASTER TO MASTER_AUTO_POSITION to restart if you use GTID, or execute SET GLOBAL sql_slave_skip_counter = 1 for classic replication. Always verify consistency with checksums before resuming traffic.

Common Scenarios and Solutions

When a column is missing on the replica, run an ALTER TABLE to add the column, then start slave. If data divergence is suspected, dump data from the master and import it into the replica, or run pt-table-checksum followed by pt-table-sync.

For corrupted relay logs, run STOP SLAVE; RESET SLAVE RELAY LOGS; START SLAVE; to fetch a fresh copy. If the error stems from unsafe non-deterministic statements, convert them to row-based logging.

Best Practices to Avoid This Error

Always use row-based replication for workload with side-effects. Deploy schema migrations through orchestrated pipelines so DDL executes in the same order on all nodes. Enable OBJECT_CHECKSUM in Galaxy or your CI pipeline to block drift before code reaches production.

Monitor SHOW SLAVE STATUS and performance_schema.replication_applier_status to catch replication stops early. Automate checksums nightly and test backups to guarantee a fast restore path.

Related Errors and Solutions

ER_DUP_ENTRY (1062) often appears when replicas diverge on unique keys. ER_BINLOG_UNSAFE_STATEMENT warns of statements that could later manifest as ER_INCONSISTENT_ERROR. ER_SLAVE_FATAL_ERROR (1593) is a generic replication stop that may wrap this error.

Each requires comparing master and replica state, aligning data, and restarting replication with consistency checks.

Common Causes

Schema Drift Between Nodes

Tables, columns, or indexes differ because a DDL ran manually on one server.

Non-Deterministic Statements

Statements that depend on UUID(), NOW(), or unordered SELECT can behave differently.

Corrupted Relay Logs

Disk issues or crashes damage relay logs, leading to misparsed events.

Trigger or Stored Routine Mismatch

Different definitions cause divergent side-effects and errors.

Related Errors

ER_DUP_ENTRY (1062)

Unique key violation can halt replication similarly.

ER_SLAVE_FATAL_ERROR (1593)

Generic fatal replication error that wraps low-level issues.

ER_BINLOG_UNSAFE_STATEMENT (1592)

Warning that statement-based logging may diverge.

FAQs

Can I ignore ER_INCONSISTENT_ERROR?

Ignoring without fixing the root cause risks silent data divergence. Always investigate, align, and verify before skipping events.

Does switching to row-based logging prevent this error?

Row-based replication removes many nondeterministic pitfalls, greatly reducing but not fully eliminating the risk.

How can Galaxy help?

Galaxy highlights schema diffs in the editor, integrates pt-table-checksum, and lets teams endorse safe migration queries to prevent drift.

Is rebuilding the replica faster?

For large drift or unclear root causes, restoring from a fresh backup or clone is often safer and quicker than manual sync.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo