How to Fix MySQL Error 1842 (ER_GTID_PURGED_WAS_CHANGED)

Published
Length
3 min read

Luis Felipe Dias

All posts

The mysql error 1842 alert happens when the server updates its global list of purged transaction identifiers. You handle it by checking your backup scripts and aligning the transaction sets across your database nodes. In the MySQL engine, this event maps to the symbol ER_GTID_PURGED_WAS_CHANGED and SQLSTATE HY000. It often shows up as a server warning or log entry rather than a hard crash. Teams see it when restoring dumps or purging old binary logs on a replica. What causes mysql error 1842

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.

The mysql error 1842 alert happens when the server updates its global list of purged transaction identifiers. You handle it by checking your backup scripts and aligning the transaction sets across your database nodes.

In the MySQL engine, this event maps to the symbol ER_GTID_PURGED_WAS_CHANGED and SQLSTATE HY000. It often shows up as a server warning or log entry rather than a hard crash. Teams see it when restoring dumps or purging old binary logs on a replica.

What causes mysql error 1842 in your database

MySQL uses global transaction identifiers to track every change across a primary server and its replicas. The engine stores these identifiers in binary log files on disk. Over time, the server removes old binary logs to save disk space.

When the server deletes a binary log, it still remembers the transaction numbers from that file. It moves those numbers into a global purged list. Every time that list changes, the database engine records code 1842 with the old and new values.

This message also appears during database imports and restores. Logical backup tools often write a statement at the top of the dump file. That statement updates the purged transaction list on the target server so replication stays in sync.

If an admin or script runs that update, MySQL logs the change right away. This tells your team that the server altered its transaction history. If the new set conflicts with existing data, replication stops working.

How to diagnose and fix the issue safely

First, check whether you are seeing an informational log notice or a blocked restore. Read the exact message text to see the previous value and the new value. Compare both sets with the transaction state on your primary database server.

If the alert happened during a routine binary log purge, no fix is needed. The server is just recording that it cleaned up old log files. You should verify that all replicas have already read those transactions before they vanished.

MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If the notice appears during a data import, inspect how you generated the backup file. When moving data to a fresh server with its own history, purging rules matter. You might need to append the purged range instead of replacing the existing set.

When you restore data into a test database, you may not need transaction tracking at all. Tell your export tool to omit transaction state data when creating dumps for local testing. This prevents the restore script from changing global variables on the target machine.

Preventing replication drift during admin tasks

Changing global transaction state requires high-level system permissions in MySQL. You should never grant those broad rights to standard user accounts or daily app roles. Giving apps permission to alter global variables creates a major risk for replication drift.

Instead, restrict system variable updates to dedicated maintenance roles. Review every restore script before running it against a live cluster. Check the current executed and purged sets on both the source and replica nodes first.

When your team runs manual database maintenance, every query should pass through a central control point. You can require peer approval before anyone alters global replication state. Data masking also rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results.

Keeping strict limits on admin sessions stops accidental changes to the purged transaction list. Your replicas stay aligned with the primary node, and your backups restore without breaking the cluster.

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

Is MySQL error 1842 a fatal failure or a warning?

It is usually a warning or informational log note with SQLSTATE HY000. The server records it to show that the global purged transaction list changed from one value to another.

Why does this message show up when restoring a backup?

Logical backup tools often include a command to update the purged transaction set on the target server. When the restore runs that command, MySQL logs code 1842 to record the state change.

Can a purged transaction mismatch break replication?

Yes, if the primary server purges transactions that a replica still needs, the replica cannot catch up. You must rebuild the replica from a fresh backup that includes the latest transaction state.

The query runs. The emails stay hidden.