跳转到主要内容

checkpoint:检查点与脏页刷盘

查看最近 checkpoint / restartpoint、累计 bgwriter / backend 刷盘比例、速率及检查点参数。

读取 sys_control_checkpoint()、sys_stat_bgwriter 与检查点配置(checkpoint_timeout、max_wal_size、checkpoint_completion_target、checkpoint_warning、log_checkpoints);只读查询,绝不执行 CHECKPOINT。

统计自 stats_reset 起累计;备库上的 checkpoints_timed 统计的是 restartpoint 尝试次数(无新检查点记录时每 15s 计一次),不能与主库直接横向对比。

用法

kbdiag checkpoint
kbdiag checkpoint --json

常用参数

参数说明
--json输出结构化 JSON(checkpoint.last、checkpoint.stats、checkpoint.settings)

判定与输出解读

  • OK(exit=0):三项探针全部采集成功(纯展示语义,不凭累计计数直接判告警)。
  • UNKNOWN(exit=3):任一探针超时、报错或无权限。
  • [NEXT] 引导:当请求检查点多于定时检查点或存在 buffers_backend_fsync > 0 时指向 kbdiag wal;未开 log_checkpoints 时给出检查建议。

实测示例(KES V9 主库,80 列)

checkpoint  OK  (primary, system@local, endpoint=/tmp/.s.KINGBASE.54321,
    2026-12-02T16:12:53Z)
[LAST CHECKPOINT]
  time  2026-12-02T16:04:29Z  (8m 25s ago)
  redo  10/400FB450  (000000010000001000000040)
[STATISTICS]
  stats_reset=2026-11-29T09:11:20Z (3d 7h ago)
  checkpoints           673: 673 timed, 0 requested (0%; requested covers WAL
    volume, CHECKPOINT, base backups, promotion)
  write, sync time      3m 57s, 704 ms
  buffers written       12929: checkpointer 2226 (17%), bgwriter 0 (0%),
    backends and others 10703 (83%)
  buffers allocated     9927
  backend fsyncs        0
  bgwriter stopped      0 times at bgwriter_lru_maxpages
  window average rates  0.002 checkpoints/s; 0.002 timed/s; 0.000 requested/s
  buffer rates          0.05 blocks/s written (checkpoint 0.01, bgwriter 0.00,
    backend 0.04); 0.03 blocks/s allocated
[SETTINGS]
  checkpoint_timeout            5m 0s
  max_wal_size                  1024 MB
  checkpoint_completion_target  0.5
  checkpoint_warning            30s
  log_checkpoints               off
[NEXT]
  SHOW log_checkpoints  # consider enabling log_checkpoints = on for timing and
    write/sync logs

关联命令

  • kbdiag wal — 查看 WAL 体量、max_wal_size 与复制槽保留原因
  • kbdiag wal(wal archive)— 检查归档进程与 .ready 积压
  • kbdiag progress — 查看正在执行的 CHECKPOINT 进度