【 TiDB 使用环境`】生产
【 TiDB 版本】5.4.2
【遇到的问题】
一个下游备份库,只做查询。数据通过cdc 同步,最近频繁出现region is unavaliable,导致cdc崩溃
【问题现象及影响】
出现 Region is unavailable,
之后etcd 事务频繁失败,导致cdc 不可用。无法pause任务,跳过异常表
cdc 日志
cdc.log.gz (2.0 MB)
新建表 就出现问题。SQL如下
建表
CREATE TABLE `tbl_ad_video_callback_log1` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`appId` INT(11) DEFAULT NULL COMMENT '应用id',
`userId` INT(11) DEFAULT NULL COMMENT '用户id',
`adCodeId` INT(11) DEFAULT NULL COMMENT '代码位id',
`dspId` INT(11) DEFAULT NULL COMMENT 'dspid',
`type` TINYINT(3) DEFAULT NULL COMMENT '处理类型:1 解析成功、 2 解析失败、 3 无解析秘钥',
`log` VARCHAR(500) DEFAULT NULL COMMENT '入参信息',
`create_time` DATETIME NOT NULL,
`platformId` INT(11) DEFAULT NULL COMMENT '平台id',
PRIMARY KEY (`id`,create_time) /*T![clustered_index] CLUSTERED */,
KEY `idx_audp` (`appId`,`userId`,`dspId`,`platformId`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=20862102 COMMENT='激励视频有效回调日志信息'
PARTITION BY RANGE COLUMNS(`create_time`)
(PARTITION `p20220817` VALUES LESS THAN ("20220818"),
PARTITION `p20220818` VALUES LESS THAN ("20220819"),
PARTITION `p20220819` VALUES LESS THAN ("20220820"),
PARTITION `p20220820` VALUES LESS THAN ("20220821"),
PARTITION `p20220821` VALUES LESS THAN ("20220822"),
PARTITION `p20220822` VALUES LESS THAN ("20220823"),
PARTITION `p20220823` VALUES LESS THAN ("20220824"),
PARTITION `p20220824` VALUES LESS THAN ("20220825"),
PARTITION `p20220825` VALUES LESS THAN ("20220826"),
PARTITION `p20220826` VALUES LESS THAN ("20220827"),
PARTITION `p20220827` VALUES LESS THAN ("20220828"),
PARTITION `p20220828` VALUES LESS THAN ("20220829"),
PARTITION `p20220829` VALUES LESS THAN ("20220830"),
PARTITION `p20220830` VALUES LESS THAN ("20220831"),
PARTITION `p20220831` VALUES LESS THAN ("20220901"))
插入数据
INSERT INTO tbl_ad_video_callback_log1 SELECT * FROM tbl_ad_video_callback_log WHERE create_time > ‘2022-08-17’;
ALTER TABLE tbl_ad_video_callback_log RENAME TO tbl_ad_video_callback_log_old;
ALTER TABLE tbl_ad_video_callback_log1 RENAME TO tbl_ad_video_callback_log
INSERT INTO tbl_ad_video_callback_log
SELECT a.* FROM tbl_ad_video_callback_log_old a LEFT JOIN tbl_ad_video_callback_log b
ON b.id=a.id WHERE a.create_time > ‘2022-08-18’
AND b.id IS NULL