Skip to main content

MySQL slave Error_code: 1032 | MySQL slave drift | HA_ERR_KEY_NOT_FOUND


MySQL slave Error_code: 1032 | MySQL slave drift:
With several MySQL, instance with master slave replication, I have one analytics MySQL, environment which is larger in terabytes, compared to other MySQL instances in the environment. Other MySQL instances with terabytes of data are running fine master, slave replication. But this analytics environment get started generating slave Error_code :1032.
mysql> show slave status;
Near relay log: Error_code: 1032; Can't find record in '<table_name>', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log <name>-bin.000047, end_log_pos 5255306
Near master section:
Could not execute Update_rows event on table <db_name>.<table_name>; Can't find record in '<table_name>', Error_code: 1032; Can't find record in '<table_name>', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log <name>-bin.000047, end_log_pos 5255306
Retrieved_Gtid_Set: 08a4856c-47a4-11ea-93aa-0050569a2a89:54-3732
Executed_Gtid_Set: 08a4856c-47a4-11ea-93aa-0050569a2a89:1-252
MySQL error log:
[ERROR] [MY-010586] [Repl] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log '<name>-bin.000047' position 195
[Warning] [MY-010584] [Repl] Slave: Can't find record in '<table_name>' Error_code: MY-001032
Identify statements using mysqlbinlog:
Identify statement breaking slave replication using mysqlbinlog utility
$mysqlbinlog -v --include-gtids='08a4856c-47a4-11ea-93aa-0050569a2a89:54-3732' /mysql/ binlogs/<name>-bin.000047 --stop-position=5255306 | more
Here I notices huge no insert statements and huge no. of update statements for the same table in the same database.
### INSERT INTO `<db_1>`.`<ta
ble_1>`
### UPDATE `<db_1>`.`<table_1>`BINLOG '
$ mysqlbinlog -v --include-gtids='08a4856c-47a4-11ea-93aa-0050569a2a89:54-3732' /mysql/binlogs/<name>-bin.000047 --stop-position=195 | more
Here I was able to notice the same message in “show slave status” in executed GTID set.
Previous-GTIDs # 08a4856c-47a4-11ea-93aa-0050569a2a89:1-252

Retrieve Table Situation:
mysql> SHOW CREATE TABLE <table_name> \G
mysql> SHOW INDEX FROM <table_name> \G 
mysql> SHOW TABLE STATUS WHERE NAME='<table_name>' \G
Conclusion:
In this situation, I realized the table does not have primary key and application design does not suit with the use of primary key, so in absence of primary key on table slave was not able to catch up with master, slave was always remain behind with huge gap that is noticeable from the “show slave status”. In this situation on slave DML statement has to scan entire table, each row of the table, to find out the matching rows. That is the reason why slave is not able to catch up master for the table having millions of rows.
Retrieved_Gtid_Set: 08a4856c-47a4-11ea-93aa-0050569a2a89:54-3732
Executed_Gtid_Set: 08a4856c-47a4-11ea-93aa-0050569a2a89:
1-252

Explore Primary Key Check implementation at slave to avoid Error 1032 because of absence of primary key for table on slave. 
Multiple reasons for Error_code 1032:
  • Error_code: 1032; Can't find record in '<table_name>', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND;
  • slave has already deleted that row
    slave is waiting for the correct portion of the Binary Log to arrive in order to create that row
  • slave never owned a copy of that row and never will
  • slave is build using inconsistent backup
  • replication started with wrong  log position
Explore more:

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. The error Error_code: SiteCountry replication typically occurs when a row being updated on the slave doesn't exist, often fixed by skipping the offending transaction or resyncing the data between master and slave.






    ReplyDelete

Post a Comment

Popular posts from this blog

MySQL InnoDB cluster troubleshooting | commands

Cluster Validation: select * from performance_schema.replication_group_members; All members should be online. select instance_name, mysql_server_uuid, addresses from  mysql_innodb_cluster_metadata.instances; All instances should return same value for mysql_server_uuid SELECT @@GTID_EXECUTED; All nodes should return same value Frequently use commands: mysql> SET SQL_LOG_BIN = 0;  mysql> stop group_replication; mysql> set global super_read_only=0; mysql> drop database mysql_innodb_cluster_metadata; mysql> RESET MASTER; mysql> RESET SLAVE ALL; JS > var cluster = dba.getCluster() JS > var cluster = dba.getCluster("<Cluster_name>") JS > var cluster = dba.createCluster('name') JS > cluster.removeInstance('root@<IP_Address>:<Port_No>',{force: true}) JS > cluster.addInstance('root@<IP add>,:<port>') JS > cluster.addInstance('root@ <IP add>,:<port> ') JS > dba.getC...

Amazon RDS | Amzon Redshift | Big Data | Boost Performance with Amazon ElastiCache

Amazon RDS with Amazon ElastiCache for Performance: Amazon RDS supports - Oracle, MS SQL server, MySQL, Maria DB and PostgreSQL. It is a managed service offered by the Amazon.  Couple of customers have observed the performance issues during their journey with Amazon RDS with Oracle, MS SQL Server, MySQL, Maria DB and PostgreSQL. Amazon cloud engineers / database consultants / database architect and Amazon supports worked to-gather to boost the Amazon RDS performance by tuning the RDBMS configuration parameters using Amazon RDS parameter group , and have not achieved the SLA for Amazon RDS .  Amazon RDS with Multi AZ and Read Replica: Some of the the AWS professionals have suggested for vertical scaling of the Amazon RDS . It should works and its absolutely correct. In my opinion, it would be a good idea to think about the Amazon ElastiCache service with Amazon RDS for better performance and cost optimization also rather than vertically scaling the Amazon RDS . I would sug...

Needs for Graph Database

Needs for Graph Database: We are living in the era of data, data is treated more precise than gold and platinum. Most of the enterprises are trying to get more insight about the data they have it as an operational / warehouse / analytical.   Ref.: https://dist.neo4j.com/wp-content/uploads/graph-example.png To get more insight into the data, it is required to see the relationship among the data points. The challenge is how to establish the relationship among data points and the answers is Graph database. Relational databases can't help to establish the relationship among data points, due to their rigid schema, and consistent schema. Relational Database issues for data set: Number of Joins:  While fetching data from relational databases, we join many tables, these joins are complex, and consume considerable amount of computing resources, which increase the query response times. Self- joins: For database ware house / business intelligence systems using RDBMS, self-JOIN are ...