一、适用版本
·适用于 TDSQL Boundless V16.0.0 及以上版本。
·V21.6.2 版本新增 DumpWaitLock、PushAppliedIndex 字段。
·V21.6.4.0 版本新增 WaitForMemoryQuota、WaitForDiskQuota 字段,用于统计等待内存配额与磁盘配额的耗时。
二、字段说明
| 字段名 | 类型 | 描述 |
| sid | bigint unsigned | LogService 的唯一标识符 |
| rep_group_id | bigint unsigned | 复制组(RG)的 ID |
| IsRunning | bigint unsigned | Log Handler 处于运行状态的总耗时 |
| DecodeKV | bigint unsigned | 解析 Key-Value 数据的耗时 |
| SendLog | bigint unsigned | 发送 Binlog 到 peer Client 的耗时 |
| GetUserRgList | bigint unsigned | 获取 User RG 列表的耗时 |
| SendMsg | bigint unsigned | 向 peer Client 发送消息的耗时 |
| UpdateCommitTsBarrier | bigint unsigned | 更新提交时间戳屏障的耗时 |
| WaitParentRg | bigint unsigned | 等待父复制组数据就绪的耗时 |
| WaitVanishedRgDispatch | bigint unsigned | 等待已移除复制组调度的耗时 |
| WaitSysRgOrVanishedRgCommitTsAdvance | bigint unsigned | 等待系统复制组或已移除复制组提交时间戳推进的耗时 |
| WaitUsrRgCommitTsAdvance | bigint unsigned | 等待用户复制组提交时间戳推进的耗时 |
| GetVanishedRgMinBarrier | bigint unsigned | 获取已移除复制组最小屏障的耗时 |
| WaitRaftLog | bigint unsigned | 等待 Raft 日志同步的耗时 |
| GetMergeLogJobIdStat | bigint unsigned | 获取日志合并任务状态的耗时 |
| WaitAllMergeLogApplied | bigint unsigned | 等待所有合并日志回放完成的耗时 |
| GetRaftLogFromBackup | bigint unsigned | 从备份中获取 Raft 日志的耗时 |
| WaitRaftNodeShutDown | bigint unsigned | 等待 Raft 节点关闭的耗时 |
| GetRaftLogFromBackupFinish | bigint unsigned | 从备份中获取 Raft 日志完成的耗时 |
| RaftOnApply | bigint unsigned | 回放 Raft 日志的耗时 |
| BackupRaftApply | bigint unsigned | 回放从备份中获取的 Raft 日志的耗时 |
| GetRaftLogFromBackupInExitProcess | bigint unsigned | 节点退出过程中从备份获取 Raft 日志的耗时 |
| BatchKVFlushToDisk | bigint unsigned | 当 RG 内存占用超过 per-RG 配额时,批量将 batch_row 数据写入 RocksDB 释放内存所产生的耗时 |
| WaitCachedMsgConsumed | bigint unsigned | Binlog Dump 模式下,等待缓存消息被消费的耗时 |
| WaitAllRepGroupRun | bigint unsigned | Binlog Dump 模式下,等待所有复制组开始回放的耗时 |
| DumpWaitLock | bigint unsigned | Binlog Dump 模式下,等待消息推送锁的耗时 |
| WaitGlobalTsBarrierAdvanced | bigint unsigned | Binlog Dump 模式下,等待全局时间戳屏障推进的耗时 |
| WaitForMemoryQuota | bigint unsigned | 等待内存配额的耗时 |
| WaitForDiskQuota | bigint unsigned | 等待磁盘配额的耗时 |
| PushAppliedIndex | bigint unsigned | 推送已应用日志索引的耗时 |
注意:说明:
三、示例
tdsql > SELECT * FROM INFORMATION_SCHEMA.LOGSERVICE_ELAPSED LIMIT 1\\G*************************** 1. row *************************** sid: 29629282460369180 rep_group_id: 257 IsRunning: 6 DecodeKV: 13 SendLog: 0 GetUserRgList: 0 SendMsg: 3 UpdateCommitTsBarrier: 0 WaitParentRg: 0 WaitVanishedRgDispatch: 0WaitSysRgOrVanishedRgCommitTsAdvance: 10 WaitUsrRgCommitTsAdvance: 0 GetVanishedRgMinBarrier: 0 WaitRaftLog: 1017 GetMergeLogJobIdStat: 0 WaitAllMergeLogApplied: 0 GetRaftLogFromBackup: 0 WaitRaftNodeShutDown: 0 GetRaftLogFromBackupFinish: 0 RaftOnApply: 0 BackupRaftApply: 0 GetRaftLogFromBackupInExitProcess: 0 BatchKVFlushToDisk: 5 WaitCachedMsgConsumed: 0 WaitAllRepGroupRun: 0 DumpWaitLock: 0 WaitGlobalTsBarrierAdvanced: 0 WaitForMemoryQuota: 0 WaitForDiskQuota: 0 PushAppliedIndex: 01 row in set (0.00 sec)
结果解读:
·该复制组(ID: 257)的主要耗时集中在 WaitRaftLog(1017s),表明 Raft 日志同步是当前的主要瓶颈
·DecodeKV 和 BatchKVFlushToDisk 也有一定耗时,反映了解码和磁盘操作的开销
·其他多数阶段耗时接近零,说明这些环节当前没有产生时耗
四、BatchKVFlushToDisk 字段说明
BatchKVFlushToDisk 记录 LogService 在 MySQL 模式下,RG 内存占用超过 per-RG 配额时,批量将 batch_row 数据写入 RocksDB 释放内存所消耗的时间。
触发落盘的参数如下:
| 参数名 | 类型 | 默认值 | 取值范围 | 说明 |
| binlog_mysqlclient_cache_max_size | ulonglong | 1 GB | [1 GB, 64 GB] | binlog mysqlclient 全局内存软限制。当总内存占用超过此值时,非全局最小 commit_ts 的 RG 将触发 batch_row 落盘以释放内存 |
| log_service_per_rg_mem_limit | ulonglong | 100 MB | [1 MB, UINT64_MAX] | 每个复制组(RG)的内存配额。单个 RG 内存超限时触发该 RG 的 batch_row 落盘 |
落盘的累积统计(写入批次/字节数、回读行数/字节数、当前驻盘数据量等)可通过 INFORMATION_SCHEMA.LOGSERVICE_MEMORY_STAT 视图查询。