MySQL 1840

This error occurs when attempting to set GTID_PURGED when GTID_EXECUTED is not empty. It indicates that the GTID_EXECUTED must be empty before GTID_PURGED can be set.

How It Affects Your App

This error indicates that the application is attempting to set the GTID_PURGED variable to a value other than the empty string when the GTID_EXECUTED variable is not empty. This can cause the application to fail, as the GTID_EXECUTED variable must be empty before the GTID_PURGED variable can be set. This can lead to data inconsistency and data loss, as the application will not be able to properly track the changes made to the database. Additionally, the application may not be able to properly recover from a crash or other unexpected event.

How To Fix

1. Check the error log for the MySQL 1840 instance to identify the root cause of the issue.
mysql> SHOW GLOBAL VARIABLES LIKE 'log_error';
+---------------+-----------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------+
| log_error | /var/log/mysql/mysql_error.log |
+---------------+-----------------------------------------+
2. Once the root cause of the issue is identified, use the appropriate SQL commands to fix the issue.
mysql> ALTER TABLE table_name DROP COLUMN column_name;
Query OK, 0 rows affected (0.02 sec)
3. After the issue is fixed, check the error log again to make sure the issue is resolved.
mysql> SHOW GLOBAL VARIABLES LIKE 'log_error';
+---------------+-----------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------+
| log_error | /var/log/mysql/mysql_error.log |
+---------------+-----------------------------------------+
4. Finally, it is recommended to use an automated database observability tool to monitor and fix the MySQL 1840 in question. This tool can help identify potential issues before they become a problem, as well as provide real-time insights into the performance of the database. It can also provide alerts when certain thresholds are exceeded, allowing for quick and efficient resolution of any issues that may arise.

Metis takes your database to the next level

The only way to

your database

Never worry about your
database again!

Start using Metis and get your database guardrails set up in minutes