Error
Error Code:
1840
MySQL Error 1840: Cannot Set GTID_PURGED with Active GTID
Description
This error occurs when attempting to set the `@@GLOBAL.GTID_PURGED` system variable on a MySQL server where `@@GLOBAL.GTID_EXECUTED` is not empty. MySQL enforces this restriction as a safety mechanism to prevent data inconsistencies and replication issues that could arise from incorrectly manipulating the GTID history while transactions have already been executed.
Error Message
@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
Known Causes
4 known causesAttempting GTID_PURGED Reset on Active Server
This error occurs when you try to set `@@GLOBAL.GTID_PURGED` on a MySQL server that has already executed transactions and thus has a non-empty `@@GLOBAL.GTID_EXECUTED` set.
Improper GTID Replication Setup or Recovery
During the setup of GTID-based replication or a recovery process, `GTID_PURGED` might be incorrectly set before the `GTID_EXECUTED` state is properly handled or cleared.
Non-Empty GTID_EXECUTED on New Replica
A common scenario is attempting to provision a new replica or reset a server's GTID state without first ensuring that `@@GLOBAL.GTID_EXECUTED` is empty, which is a prerequisite for setting `GTID_PURGED`.
Direct Manual GTID_PURGED Manipulation
Trying to manually set `GTID_PURGED` via a `SET GLOBAL` statement without proper context of the server's executed GTID history can trigger this error.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service