mysql server power off Got fatal error 1236

created at 10-20-2021 views: 6

The computer room was powered off, and after mysql started, an error was reported from the library:

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log:
'Client requested master to start replication from position > file size; 
the first event 'binlog.000140' at 1009874186, 
the last event read from '/home/mysql/binlog/binlog.000140' at 4,
the last byte read from '/home/mysql/binlog/binlog.000140' at 4.'

solution

mysqlbinlog /home/mysql/binlog/binlog.000140>my.log

[root@dev-env-22 binlog]# tail -f my.log
'/*!*/;
# at 1009594103
#211019 15:28:58 server id 1 end_log_pos 1009594134 CRC32 0xa990442b Xid = 17058793169
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog *//*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

It is found that end_log_pos 1009594134 is much smaller than the error 1009874186

Start application from end_log_pos 1009594134

stop slave;
change master to master_host='192.168.1.22',master_port=3306,master_user='repl',master_password='repl',master_log_file='binlog.000140',master_log_pos=1009594134;
start slave;

Continue to report errors

mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.22
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000141
          Read_Master_Log_Pos: 636751
               Relay_Log_File: relay-bin.000003
                Relay_Log_Pos: 288515
        Relay_Master_Log_File: binlog.000141
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 1032
                   Last_Error: Could not execute Delete_rows event on table db_miao.user_login_log; Can't find record in 'user_login_log', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log binlog.000141, end_log_pos 288719
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 288351
              Relay_Log_Space: 637273
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 1032
               Last_SQL_Error: Could not execute Delete_rows event on table db_miao.user_login_log; Can't find record in 'user_login_log', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log binlog.000141, end_log_pos 288719
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: c95fcd3a-98ae-11e5-b124-5820b106a87c
             Master_Info_File: /home/mysql/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 211019 16:42:33
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: c95fcd3a-98ae-11e5-b124-5820b106a87c:89966674-89967893
            Executed_Gtid_Set: 68a1789e-1f86-11e9-b06d-9cb654b262cc:1-2,
c95fcd3a-98ae-11e5-b124-5820b106a87c:1-26487091:26487093-89967141
                Auto_Position: 0
1 row in set (0.00 sec)

ERROR: 
No query specified

Execute on the slave library, use the tool to skip the error number

/opt/percona-toolkit-3.1.0/bin/pt-slave-restart --error-numbers=1032 -h localhost -uroot -pyeemiao3040

[root@dev-env23 ~]# /opt/percona-toolkit-3.1.0/bin/pt-slave-restart --error-numbers=1032 -h localhost -uroot -pyeemiao3040
2021-10-19T16:47:23 h=localhost,p=...,u=root relay-bin.000003 288515 1032
2021-10-19T16:47:26 h=localhost,p=...,u=root relay-bin.000003 329443 1032
2021-10-19T16:47:41 h=localhost,p=...,u=root relay-bin.000003 527565 1032
2021-10-19T16:47:42 h=localhost,p=...,u=root relay-bin.000003 576529 1032

I have not stopped, but it is normal to check the status of the slave library, and I have been waiting

created at:10-20-2021
edited at: 10-20-2021: