Error
Error Code:
1756
MariaDB Error 1756: Replication Data Inconsistency
Description
MariaDB Error 1756, identified by `ER_MTS_INCONSISTENT_DATA`, indicates that the replication slave has detected an inconsistency in the data received from the master. This error typically occurs in Multi-Threaded Slave (MTS) environments when the slave cannot apply transactions correctly, potentially leading to data divergence or replication failure.
Error Message
Replication slave data inconsistency detected.
Known Causes
3 known causesCorrupted Relay Log Files
Relay log files on the slave server may be corrupted or incomplete, preventing the accurate application of transactions.
Master-Slave Data Divergence
The data on the master and slave servers may have diverged due to manual changes on the slave, external modifications, or previously skipped transactions, causing integrity checks to fail.
Network Interruption
Brief network outages or packet loss during replication could result in incomplete or corrupted transaction data being sent from the master to the slave.
Solutions
3 solutions available1. Resynchronize Slave with Master medium
Rebuild the slave's data from a fresh master dump.
1
Stop replication on the slave.
STOP SLAVE;
2
Identify the current master binary log file and position from the slave's status. This is crucial for resuming replication correctly.
SHOW SLAVE STATUS\G
3
On the master server, create a consistent dump of the database(s) that are experiencing inconsistency. Ensure all tables are dumped, including those with potential issues.
mysqldump --single-transaction --master-data=2 --flush-logs -u <master_user> -p<master_password> <database_name> > /path/to/slave_restore.sql
4
Stop the slave MySQL server.
sudo systemctl stop mariadb
5
On the slave server, clear the existing data directory (or relevant databases if possible and safe). **WARNING: This will delete all data on the slave! Backup is essential.**
sudo rm -rf /var/lib/mysql/*
6
Restore the dump file to the slave server.
sudo mariadb < /path/to/slave_restore.sql
7
Configure the slave to connect to the master using the binary log file and position identified earlier. Replace `<master_host>`, `<master_user>`, `<master_password>`, and the file/position values accordingly.
CHANGE MASTER TO MASTER_HOST='<master_host>', MASTER_USER='<master_user>', MASTER_PASSWORD='<master_password>', MASTER_LOG_FILE='<master_log_file>', MASTER_LOG_POS=<master_log_pos>;
8
Start replication on the slave.
START SLAVE;
9
Monitor slave status to ensure it's catching up and the inconsistency is resolved.
SHOW SLAVE STATUS\G
2. Skip Inconsistent Transaction (Use with Extreme Caution) advanced
Force the slave to ignore the current problematic transaction.
1
Stop replication on the slave.
STOP SLAVE;
2
Identify the binary log file and position where the inconsistency occurred. This is often indicated in the slave status or error logs.
SHOW SLAVE STATUS\G
3
Tell the slave to skip the current transaction. **This is a quick fix but can lead to further data divergence if not understood.**
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
4
Start replication on the slave.
START SLAVE;
5
Immediately investigate the cause of the inconsistency on the master. This might involve analyzing queries, triggers, or application logic that ran around the time of the error.
text
(Manual investigation required)
6
After investigation, consider a more permanent fix on the master and potentially re-synchronizing the slave if the skipped transaction was critical.
text
(Manual intervention and potential resynchronization)
3. Verify Master and Slave Configurations easy
Ensure replication settings and server configurations are consistent.
1
On both master and slave, check `server_id` settings in `my.cnf` or `my.ini`. They must be unique and non-zero.
text
# In my.cnf / my.ini
[mysqld]
server-id = <unique_id>
2
On the master, ensure `log_bin` is enabled and `binlog_format` is set (e.g., `ROW` or `MIXED`).
text
# In my.cnf / my.ini
[mysqld]
log-bin = mysql-bin
binlog_format = ROW
3
On the slave, ensure `relay_log` is configured.
text
# In my.cnf / my.ini
[mysqld]
relay-log = mysql-relay-bin
4
Check `read_only` setting on the slave. It should typically be enabled to prevent accidental writes that could cause divergence.
text
# In my.cnf / my.ini
[mysqld]
read-only = 1
5
Restart MySQL services on both servers after any configuration changes.
sudo systemctl restart mariadb
6
Verify replication status.
SHOW SLAVE STATUS\G