首批通过分布式安全可靠测评,为关键业务系统打造
clog 同步延迟
更新时间:2026-04-14 15:15:54
本节为您介绍 OceanBase 租户的监控指标 clog 同步延迟 。该指标细分为三个指标,分别为 full_clog_sync_delay(全能型副本 clog 同步延迟)、 readonly_clog_sync_delay(只读型副本 clog 同步延迟)和 logonly_clog_sync_delay(日志型副本 clog 同步延迟)。您可指定统计范围,查询租户在单个 Zone 或 OBServer 节点的 clog 同步延迟 数据。
OceanBase 数据库中副本类型也有以下几种:
全能型副本:目前支持的普通副本,拥有事务日志、MemTable 和 SSTable 等全部完整的数据和功能。它可以随时快速切换为 Leader 以对外提供服务。
日志型副本:只包含日志的副本,没有 MemTable 和 SSTable。它参与日志投票并对外提供日志服务,可以参与其他副本的恢复,但自身不能变为主提供数据库服务。
只读型副本:包含完整的日志、MemTable 和 SSTable 等。但是它的日志比较特殊,它不作为 Paxos 成员参与日志的投票,而是作为一个观察者实时追赶 Paxos 成员的日志,并在本地回放。这种副本可以在业务对读取数据的一致性要求不高的时候提供只读服务。因其不加入 Paxos 成员组,又不会造成投票成员增加导致事务提交延时的增加。
clog 同步延迟是指这些副本 clog 的同步延迟。
full_clog_sync_delay
指标介绍
统计范围内,全能型副本 clog 同步最大延迟。
指标参数说明
| 指标项 | 指标名称 | 单位 |
|---|---|---|
| full_clog_sync_delay | max_full_clog_sync_delay_seconds | s |
计算表达式
max(ob_clog_max_sync_delay_seconds{replica_type="0",@LABELS}) by (@GBLABELS)
采集 SQL
OceanBase V4.0 以下版本:
select /*+ MONITOR_AGENT READ_CONSISTENCY(WEAK) */ stat.table_id >> 40 tenant_id, stat.replica_type, max(stat.next_replay_ts_delta) / 1000000 as max_clog_sync_delay_seconds from __all_virtual_clog_stat stat left join (select meta.table_id, meta.partition_id from __all_virtual_meta_table meta where meta.status = 'REPLICA_STATUS_NORMAL'and meta.svr_ip = ? and meta.svr_port = ? and meta.table_id not in (select table_id from __all_virtual_partition_migration_status mig where mig.action <> 'END') ) meta on stat.table_id = meta.table_id and stat.partition_idx = meta.partition_id where stat.svr_ip = ? and stat.svr_port = ? group by tenant_id, replica_type having max_clog_sync_delay_seconds < 3153600000OceanBase V4.0 及以上版本:
select /* MONITOR_AGENT */ leader.tenant_id, '0' as replica_type, abs(max(CAST(leader_ts as SIGNED)-CAST(follower_ts as SIGNED)))/1000000000 max_clog_sync_delay_seconds from (select max(end_scn) leader_ts, tenant_id, role from GV$OB_LOG_STAT where role='LEADER' group by tenant_id ) leader inner join (select min(end_scn) follower_ts, tenant_id, role from GV$OB_LOG_STAT where role='FOLLOWER' group by tenant_id ) follower on leader.tenant_id=follower.tenant_id group by leader.tenant_id
readonly_clog_sync_delay
指标介绍
统计范围内,只读型副本 clog 同步最大延迟。
指标参数说明
| 指标项 | 指标名称 | 单位 |
|---|---|---|
| readonly_clog_sync_delay | max_logonly_clog_sync_delay_seconds | s |
计算表达式
max(ob_clog_max_sync_delay_seconds{replica_type="5",@LABELS}) by (@GBLABELS)
采集 SQL
OceanBase V4.0 以下版本:
select /*+ MONITOR_AGENT READ_CONSISTENCY(WEAK) */ stat.table_id >> 40 tenant_id, stat.replica_type, max(stat.next_replay_ts_delta) / 1000000 as max_clog_sync_delay_seconds from __all_virtual_clog_stat stat left join (select meta.table_id, meta.partition_id from __all_virtual_meta_table meta where meta.status = 'REPLICA_STATUS_NORMAL'and meta.svr_ip = ? and meta.svr_port = ? and meta.table_id not in (select table_id from __all_virtual_partition_migration_status mig where mig.action <> 'END') ) meta on stat.table_id = meta.table_id and stat.partition_idx = meta.partition_id where stat.svr_ip = ? and stat.svr_port = ? group by tenant_id, replica_type having max_clog_sync_delay_seconds < 3153600000OceanBase V4.0 及以上版本:
select /* MONITOR_AGENT */ leader.tenant_id, '0' as replica_type, abs(max(CAST(leader_ts as SIGNED)-CAST(follower_ts as SIGNED)))/1000000000 max_clog_sync_delay_seconds from (select max(end_scn) leader_ts, tenant_id, role from GV$OB_LOG_STAT where role='LEADER' group by tenant_id ) leader inner join (select min(end_scn) follower_ts, tenant_id, role from GV$OB_LOG_STAT where role='FOLLOWER' group by tenant_id ) follower on leader.tenant_id=follower.tenant_id group by leader.tenant_id
logonly_clog_sync_delay
指标介绍
统计范围内,日志型副本 clog 同步最大延迟。
指标参数说明
| 指标项 | 指标名称 | 单位 |
|---|---|---|
| logonly_clog_sync_delay | max_readonly_clog_sync_delay_seconds | s |
计算表达式
max(ob_clog_max_sync_delay_seconds{replica_type="16",@LABELS}) by (@GBLABELS)
采集 SQL
OceanBase V4.0 以下版本:
select /*+ MONITOR_AGENT READ_CONSISTENCY(WEAK) */ stat.table_id >> 40 tenant_id, stat.replica_type, max(stat.next_replay_ts_delta) / 1000000 as max_clog_sync_delay_seconds from __all_virtual_clog_stat stat left join (select meta.table_id, meta.partition_id from __all_virtual_meta_table meta where meta.status = 'REPLICA_STATUS_NORMAL'and meta.svr_ip = ? and meta.svr_port = ? and meta.table_id not in (select table_id from __all_virtual_partition_migration_status mig where mig.action <> 'END') ) meta on stat.table_id = meta.table_id and stat.partition_idx = meta.partition_id where stat.svr_ip = ? and stat.svr_port = ? group by tenant_id, replica_type having max_clog_sync_delay_seconds < 3153600000OceanBase V4.0 及以上版本:
select /* MONITOR_AGENT */ leader.tenant_id, '0' as replica_type, abs(max(CAST(leader_ts as SIGNED)-CAST(follower_ts as SIGNED)))/1000000000 max_clog_sync_delay_seconds from (select max(end_scn) leader_ts, tenant_id, role from GV$OB_LOG_STAT where role='LEADER' group by tenant_id ) leader inner join (select min(end_scn) follower_ts, tenant_id, role from GV$OB_LOG_STAT where role='FOLLOWER' group by tenant_id ) follower on leader.tenant_id=follower.tenant_id group by leader.tenant_id