GreatSQL一个关于主从复制的限制描述与规避( 二 )

根据slave status状态信息可以看出

  • 报错的GTID为:'9e668a93-2618-11ee-93ee-bc16954181bb:47508257'
  • 应用的主集群的binlog为:greatsql-bin.000988
  • 【GreatSQL一个关于主从复制的限制描述与规避】灾备集群的relay log为:greatsql-relay.002963
详细信息查看performance_schema.replication_applier_status_by_worker
2、查看错误的详细信息greatsql> select * from performance_schema.replication_applier_status_by_workerG*************************** 1. row ***************************         CHANNEL_NAME:            WORKER_ID: 1            THREAD_ID: NULL        SERVICE_STATE: OFFLAST_SEEN_TRANSACTION: 9e668a93-2618-11ee-93ee-bc16954181bb:47508257    LAST_ERROR_NUMBER: 1146   LAST_ERROR_MESSAGE: Worker 1 failed executing transaction'9e668a93-2618-11ee-93ee-bc16954181bb:47508257' at master log greatdb-bin.000988,end_log_pos 701570116; Error executing row event: 'Table 'abs_xxx.tmp_xxx_info' doesn't exist'LAST_ERROR_TIMESTAMP: 2023-08-22 14:14:18上述信息说明根据performance_schema.replication_applier_status_by_worker表中的详细错误信息可以发现为灾备集群abs_xxx.tmp_xxx_info表不存在,导致同步报错
3、问题分析3.1、确认灾备集群中目标表是否存在
greatsql> show create table abs_xxx.tmp_xxx_info;ERROR 1146 (42S02): Table 'abs_xxx.tmp_xxx_info' doesn't existgreatsql> desc abs_xxx.tmp_xxx_info;ERROR 1146 (42S02): Table 'abs_xxx.tmp_xxx_info' doesn't exist结论:灾备集群中目标表的确不存在
3.2、根据主从报错信息解析主集群binlog,报错的SQL
解析主集群binlog
SET @@SESSION.GTID_NEXT= '9e668a93-2618-11ee-93ee-bc16954181bb:47508257'/*!*/;……#230822 14:14:18 server id 1943306  end_log_pos 701570000         Table_map: `abs_xxx`.`tmp_xxx_info` mapped to number 1595# at 701570000#230822 14:14:18 server id 1943306  end_log_pos 701570116         Write_rows: table id 1595 flags: STMT_END_F### INSERT INTO `abs_xxx`.`tmp_xxx_info`### SET###   @1=2###   @2='自动化'###   @3='2300121212120000'###   @4='90000000'###   @5='1'###   @6='202001290231001'###   @7='2021-01-31 00:00:00'# at 701570116#230822 14:14:18 server id 1943306  end_log_pos 701570143         Xid = 800998400COMMIT/*!*/;# at 701570143#230822 14:14:18 server id 1943306  end_log_pos 701570204         GTID        last_committed=26491        sequence_number=26521        rbr_only=yes/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;结论:根据复制的报错信息得知具体的GTID号以及主集群的binlog文件,解析binlog得知此事务为一条INSERT语句 , 语句中的目标表与performance_schema.replication_applier_status_by_worker表中信息一致
3.3、寻找主集群目标表binlog中是否有建表语句
在同一binlog日志中寻找建表语句
SET TIMESTAMP=1692684495/*!*/;CREATE DATABASE IF NOT EXISTS `abs_xxx` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin *//*!*/;……use `information_schema`/*!*/;SET TIMESTAMP=1692684495/*!*/;CREATE TABLE `abs_xxx`.`tmp_xxx_info` (  `ID` int(64) NOT NULL AUTO_INCREMENT,  `CUSTOMER_NAME` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,  `CUSTOMER_NUM` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,  `PRODIST_SKU_NUM` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL,  `STATUS` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL,  `AGREEMENT_NUM` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,  `END_DATE` datetime DEFAULT NULL,  PRIMARY KEY (`ID`),  KEY `PK_PRODIST_SKU_NUM_AGREEMENT` (`PRODIST_SKU_NUM`) USING BTREE,  KEY `IDX_AGREEMENT_NUM` (`AGREEMENT_NUM`) USING BTREE) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC/*!*/;# at 475864451


推荐阅读