【 TiDB 使用环境】
- 生产
【 TiDB 版本】
- v5.1.4
【遇到的问题】
-
集群拓扑:3台物理机6个
TiDB Server
实例(TiKV
和Prometheus
在其他物理机,不在这三台),上层用HaProxy 做的负载均衡,问题流量不均匀 -
以下是
TiDB Server
的部分监控,截取了CPU
使用率 和连接数
,如下:
-
从
Dashboard
看到,几乎慢查都集中在某一到两个实例上
-
相关的
UPDATE
语句如下,id
为主键,每个SQL
值不一样:
## create table
CREATE TABLE `Music_GorillaGatewayRecord` (
`id` bigint(20) NOT NULL COMMENT '',
`processType` varchar(32) NOT NULL COMMENT '',
`appName` varchar(64) NOT NULL COMMENT '',
`sdkVersion` varchar(32) NOT NULL COMMENT '',
`businessType` varchar(32) NOT NULL COMMENT '',
`ip` varchar(64) DEFAULT NULL COMMENT '',
`status` int(4) NOT NULL COMMENT '',
`result` text DEFAULT NULL COMMENT '',
`callback` text DEFAULT NULL COMMENT '',
`batch` tinyint(2) NOT NULL DEFAULT '0' COMMENT '',
`count` int(4) NOT NULL DEFAULT '1' COMMENT '',
`retry` int(4) NOT NULL DEFAULT '0' COMMENT '',
`callback_Encrypt2013` longtext DEFAULT NULL COMMENT '',
`createTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`,`createTime`) /*T![clustered_index] NONCLUSTERED */,
KEY `idx_appName_bType_status` (`appName`,`businessType`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin/*!90000 SHARD_ROW_ID_BITS=5 */ COMMENT=''
PARTITION BY RANGE ( TO_DAYS(`createTime`) ) (
PARTITION `p20220701` VALUES LESS THAN (738702),
PARTITION `p20220801` VALUES LESS THAN (738733),
PARTITION `p20220901` VALUES LESS THAN (738764),
PARTITION `p20221001` VALUES LESS THAN (738794),
PARTITION `p20221101` VALUES LESS THAN (738825),
PARTITION `p20221201` VALUES LESS THAN (738855),
PARTITION `p20230101` VALUES LESS THAN (738886),
PARTITION `p20230201` VALUES LESS THAN (738917),
PARTITION `p20230301` VALUES LESS THAN (738945)
)
## 操作SQL语句
UPDATE Music_GorillaGatewayRecord SET status = 30 WHERE id =385804593597091847 AND status <30 limit 1;
最后,各位社区的大佬,遇到这种有什么优化手段,不甚感激