How to Fix MySQL Error 3649 (ER_CORRUPTED_JSON_DIFF)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 3649 when the database reads a bad partial JSON update. You can fix it by rebuilding the broken row from the source server. This failure uses the symbol ER_CORRUPTED_JSON_DIFF and returns SQLSTATE HY000. The server message reports a corrupted JSON diff for a specific table and column. It often stops replica servers during binary log playback. Teams must find the bad event and repair the target row to restore sync. What causes mysql error 3649 in your database MySQL can se

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 3649 when the database reads a bad partial JSON update. You can fix it by rebuilding the broken row from the source server.

This failure uses the symbol ER_CORRUPTED_JSON_DIFF and returns SQLSTATE HY000. The server message reports a corrupted JSON diff for a specific table and column. It often stops replica servers during binary log playback. Teams must find the bad event and repair the target row to restore sync.

What causes mysql error 3649 in your database

MySQL can send small JSON changes instead of full documents to save space. These small changes are called JSON diffs. The primary server writes these diffs into the binary log during an update. The replica server reads the diff and applies it to the local JSON column.

Sometimes the binary log event gets damaged on disk or over the network. A bug or a memory fault can also create a bad diff payload. When the replica tries to apply the broken diff, the engine rejects it. The database stops the update and throws mysql error 3649 to prevent bad data.

This error can also happen if the replica data does not match the source. If a past write was skipped, the base JSON document will have the wrong shape. The incoming diff will point to a path or length that does not exist. The storage engine flags this mismatch as a corrupted diff and halts the thread.

How to find the broken table and column

Start by reading the error log or the replica status output on your server. The error message names the exact table and column that failed the check. Note the binary log file name and the position where the thread stopped. This tells you which change caused the failure.

Next, inspect the binary log event at that exact position on the primary server. Compare the event payload with the relay log event on the replica server. If the relay log file is damaged, the network transfer or disk write failed. If both logs match, the replica row had drifted before the update arrived.

JSON Web Tokens (JWT) + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Check the primary and replica rows for that specific record key. Look at the JSON column values on both sides to see where they differ. Do not grant full admin rights to every engineer during this check. Use read-only roles to inspect the rows and protect sensitive fields like emails.

How to fix ER_CORRUPTED_JSON_DIFF in production

If the relay log on the replica is damaged, fetch a fresh copy. Stop the replica thread and reset the relay log queue from the current spot. Start the thread again so it pulls a clean event from the primary server. This fixes transient network or disk errors right away.

If the base row on the replica drifted, you must repair the row data. Copy the full, valid JSON document for that row from the primary server. Write the full document to the replica row so both servers match again. Then skip the single failing diff event and start the replica thread.

To prevent future stops, you can turn off partial JSON replication in your settings. Sending full JSON documents uses more network space, but it avoids diff mismatches. After the fix, run a table checksum to make sure no other rows drifted. Keep write permissions tight while your team runs these repair steps.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.

First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Does mysql error 3649 mean my disk is failing?

Not always. A bad disk can damage a relay log file and cause this error. Still, row drift between the primary and replica servers is a more common cause.

Can I just skip the transaction when ER_CORRUPTED_JSON_DIFF happens?

Skipping the event without fixing the row leaves bad data on your replica. Future partial updates to that same JSON column will likely fail again. Always sync the full JSON document from the primary server first.

How do I stop partial JSON diffs from breaking replication?

You can set the binary log row value options to send full JSON values. The primary server will log the whole JSON document on every update. This uses more log space, but replicas will not need to apply diffs.

The query runs. The emails stay hidden.