0

主题在 DBA 中移动

我需要一些帮助来解决这个问题:

我收到此错误:无法在表上执行 Write_rows 事件.....;键“P​​RIMARY”的重复条目“16XXXXX-\xE790\XXXXXXX-16XXXXXX”,错误代码:1062;处理程序错误 HA_ERR_FOUND_DUPP_KEY;事件的主日志 utilBINLog-bin.000029, end_log_pos 794622875

主/从之间发生故障转移。当主人成为奴隶时,这个错误发生在奴隶上。

此设置使用 GTID/BINLOG。我想避免跳过此错误(将跳过计数器设置为 ...),因为我认为这可能会引起数据库中的不一致。

mysql> SHOW SLAVE STATUS \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 
                  Master_User: 
                  Master_Port: 
                Connect_Retry: 
              Master_Log_File: utilBINLog-bin.000030
          Read_Master_Log_Pos: 1590687
               Relay_Log_File: RELAYLog.000002
                Relay_Log_Pos: 168192
        Relay_Master_Log_File: utilBINLog-bin.000029
            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: 1062
                   Last_Error: Could not execute Write_rows event on table ....; Duplicate entry '16008080-\xE790\-1600000' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the events master log utilBINLog-bin.000029, end_log_pos 794622875
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 794621018
              Relay_Log_Space: 280882085
              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: 
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1062
               Last_SQL_Error: Could not execute Write_rows event on table ...; Duplicate entry '16008080-\xE790\-1600000' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the events master log utilBINLog-bin.000029, end_log_pos 794622875
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 101
Master_UUID: a0232561-e21a-11ea-a236-005056af6c92
             Master_Info_File: mysql.slave_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: 
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: a0232561-e21a-11ea-a236-005056af6c92:10795159-10967882
            Executed_Gtid_Set: 77818f20-e21a-11ea-b443-005056af4111:1-9605354,
a0232561-e21a-11ea-a236-005056af6c92:1-10795259
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name:
           Master_TLS_Version:
       Master_public_key_path:
        Get_master_public_key: 1
            Network_Namespace:

**Master :** 


**mysql> SHOW MASTER STATUS\G**
*************************** 1. row ***************************
             File: utilBINLog-bin.000030
         Position: 1590687
     Binlog_Do_DB: ....
 Binlog_Ignore_DB:
Executed_Gtid_Set: 77818f20-e21a-11ea-b443-005056af4111:1-9585630,
a0232561-e21a-11ea-a236-005056af6c92:1-10967882
1 row in set (0.00 sec)

当我在两个数据库中搜索此记录时,没有与错误中显示的记录相对应的记录。

更多信息 - 当我在机器上显示所有二进制日志时,从站上不存在 binlog utilBINLog-bin.000029:

Binary log on slave : 

mysql> SHOW BINARY LOGS;
+-----------------------+------------+-----------+
| Log_name              | File_size  | Encrypted |
+-----------------------+------------+-----------+
| utilBINLog-bin.000001 | 1073742187 | No        |
| utilBINLog-bin.000002 | 1073743074 | No        |
| utilBINLog-bin.000003 | 1073742588 | No        |
| utilBINLog-bin.000004 |  531615680 | No        |
| utilBINLog-bin.000005 |        235 | No        |
+-----------------------+------------+-----------+
5 rows in set (0.06 sec)

Binary logs on master : 

mysql> SHOW BINARY LOGS;
+-----------------------+------------+-----------+
| Log_name              | File_size  | Encrypted |
+-----------------------+------------+-----------+
| utilBINLog-bin.000026 | 1073743702 | No        |
| utilBINLog-bin.000027 | 1073741952 | No        |
| utilBINLog-bin.000028 |  781910611 | No        |
| utilBINLog-bin.000029 | 1073742817 | No        |
| utilBINLog-bin.000030 |    4293615 | No        |
+-----------------------+------------+-----------+

两周前发生了一次硬故障转移(服务器意外重启),自上次故障转移以来,此事务是否可能“卡住”?

看来slave上的executed_GTID_set(77818f20-e21a-11ea-b443-005056af4111: 1-9605354)比当前master的executed_GTID_set(77818f20-e21a-11ea-b443-005056af4111: 1-9585630)提前了

这怎么可能?

有人说我应该做一个停止奴隶;重置从机;启动slave,但根据mysql doc,这不会改变executed_GTID_set,或者我可以注入一个假事务来告诉slave传递有问题的事务,但我不知道如何检查这个错误是否只涉及一个或多个事务.

4

0 回答 0