现场有几个注入的会话:一个 idle in transaction 的会话持有表锁、一个读这张表的会话在等它,另一个 idle in transaction 的会话,一个在等两阶段事务的会话,还有一个 pg_sleep(3600)。
~/kbdiag sessions
echoEXIT_CODE=$?
sessions OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:17+08:00)
connected: 8 client sessions (not counting kbdiag), 1 walsender, 7 background
count user database application client
2 esrep esrep internal_rwcmgr 192.168.105.10
1 esrep esrep internal_rwcmgr 192.168.105.11
1 system test kbdiag_inj_idle_txn local
1 system test kbdiag_inj_lock_holder local
1 system test kbdiag_inj_lock_waiter local
1 system test kbdiag_inj_long_query local
1 system test kbdiag_inj_prepared_waiter local
not idle: 5
pid user database application client state xact query wait sql
1045715 system test kbdiag_inj_lock_holder local idle in transaction 30s 30s - lock table kbdiag_inj_lock in access exclusive mode;
1045724 system test kbdiag_inj_lock_waiter local active 30s 30s Lock:relation select count(*) from kbdiag_inj_lock;
1045809 system test kbdiag_inj_idle_txn local idle in transaction 28s 27s - select txid_current() as kbdiag_last, pg_sleep(1);
1046007 system test kbdiag_inj_prepared_waiter local active 25s 25s Lock:relation lock table kbdiag_inj_2pc in access exclusive mode;
1046088 system test kbdiag_inj_long_query local active 24s 24s Timeout:PgSleep select pg_sleep(3600);
EXIT_CODE=0
sessions OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:20+08:00)
connected: 8 client sessions (not counting kbdiag), 1 walsender, 7 background
count user database application client
2 esrep esrep internal_rwcmgr 192.168.105.10
1 esrep esrep internal_rwcmgr 192.168.105.11
1 system test kbdiag_inj_idle_txn local
1 system test kbdiag_inj_lock_holder local
1 system test kbdiag_inj_lock_waiter local
1 system test kbdiag_inj_long_query local
1 system test kbdiag_inj_prepared_waiter local
not idle: 5
pid user database application client state xact query wait sql
1045715 system test kbdiag_inj_lock_holder local idle in transaction 33s 33s - lock table kbdiag_inj_lock in access exclusive mode;
1045724 system test kbdiag_inj_lock_waiter local active 33s 33s Lock:relation select count(*) from kbdiag_inj_lock;
... 3 more rows not shown (use --limit 0 to show all)
EXIT_CODE=0
--limit 裁的是 not idle 列表(和 --json 里的行),最后一行说明还有多少行没显示。汇总和判定仍然覆盖全部会话。
session WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:23+08:00)
[WARN] session.idle_in_txn session 1045809 has been idle in transaction for 32s
session 1045809
user system
database test
application kbdiag_inj_idle_txn
client local
type client backend
state idle in transaction (for 33s)
xact 35s
query 34s
wait -
xid / xmin 6344 / -
last sql
select txid_current() as kbdiag_last, pg_sleep(1);
waiting for: 0
blocking: 0
holds: 0
EXIT_CODE=1
kbdiag: no session with pid 999999 (it may have ended)
session UNKNOWN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:34:46+08:00)
session 999999: not found (it may have ended)
EXIT_CODE=3
{"id":"lock.waiting","level":"WARN","symptom":"session 1045724 has waited 37s for AccessShareLock on public.kbdiag_inj_lock, blocked by 1045715","evidence":[{"probe_id":"lock.list","fields":{"blocker_pids":[1045715],"lock_mode":"AccessShareLock","relation":"public.kbdiag_inj_lock","wait_s":37.3,"waiter_pid":1045724}}],"cause":null,"next":[{"kind":"verify","command":"kbdiag session 1045715","note":"what the blocking session is doing"}]}
locks WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:17+08:00)
[WARN] lock.waiting session 1045724 has waited 30s for AccessShareLock on public.kbdiag_inj_lock, blocked by 1045715
verify: kbdiag session 1045715 # what the blocking session is doing
[WARN] lock.waiting session 1046007 has waited 25s for AccessExclusiveLock on public.kbdiag_inj_2pc, blocked by an uncommitted two-phase transaction
verify: kbdiag txn # the blocker is an uncommitted two-phase transaction: its gid and how long it has been pending
blockers: 2
pid blocks holds
2PC 1 public.kbdiag_inj_2pc RowExclusiveLock
1045715 1 public.kbdiag_inj_lock AccessExclusiveLock
waiting: 2
pid object wants waited blocked by
1045724 public.kbdiag_inj_lock AccessShareLock 30s 1045715
1046007 public.kbdiag_inj_2pc AccessExclusiveLock 25s 2PC
EXIT_CODE=1
txn OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:18+08:00)
oldest xid: 6343 (1045715 xid, 1045724 xmin, 1046007 xmin, 1046088 xmin)
open transactions: 5
pid user database application state xact xid xmin sql
1045715 system test kbdiag_inj_lock_holder idle in transaction 31s 6343 - lock table kbdiag_inj_lock in access exclusive mode;
1045724 system test kbdiag_inj_lock_waiter active 30s - 6343 select count(*) from kbdiag_inj_lock;
1045809 system test kbdiag_inj_idle_txn idle in transaction 29s 6344 - select txid_current() as kbdiag_last, pg_sleep(1);
1046007 system test kbdiag_inj_prepared_waiter active 25s 6347 6343 lock table kbdiag_inj_2pc in access exclusive mode;
1046088 system test kbdiag_inj_long_query active 25s - 6343 select pg_sleep(3600);
prepared: 1
gid owner database age xid
kbdiag_inj_2pc system test 26s 6346
EXIT_CODE=0
txn WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:35:21+08:00)
[WARN] txn.long session 1045715 has had a transaction open for 34s, now idle in transaction
verify: kbdiag session 1045715 # what it is running, which locks it holds, whether it blocks anyone
[WARN] txn.long session 1045724 has had a transaction open for 34s, now active
verify: kbdiag session 1045724 # what it is running, which locks it holds, whether it blocks anyone
[WARN] txn.long session 1045809 has had a transaction open for 32s, now idle in transaction
verify: kbdiag session 1045809 # what it is running, which locks it holds, whether it blocks anyone
[WARN] txn.long session 1046007 has had a transaction open for 28s, now active
verify: kbdiag session 1046007 # what it is running, which locks it holds, whether it blocks anyone
[WARN] txn.long session 1046088 has had a transaction open for 28s, now active
verify: kbdiag session 1046088 # what it is running, which locks it holds, whether it blocks anyone
[WARN] txn.prepared two-phase transaction kbdiag_inj_2pc prepared 29s ago and not finished, holding back the vacuum horizon
fix: ROLLBACK PREPARED 'kbdiag_inj_2pc' # check with the application whether to commit (COMMIT PREPARED) or roll back; run it connected to database test, outside a transaction block
oldest xid: 6343 (1045715 xid, 1045724 xmin, 1046007 xmin, 1046088 xmin)
open transactions: 5
pid user database application state xact xid xmin sql
1045715 system test kbdiag_inj_lock_holder idle in transaction 34s 6343 - lock table kbdiag_inj_lock in access exclusive mode;
1045724 system test kbdiag_inj_lock_waiter active 34s - 6343 select count(*) from kbdiag_inj_lock;
1045809 system test kbdiag_inj_idle_txn idle in transaction 32s 6344 - select txid_current() as kbdiag_last, pg_sleep(1);
1046007 system test kbdiag_inj_prepared_waiter active 28s 6347 6343 lock table kbdiag_inj_2pc in access exclusive mode;
1046088 system test kbdiag_inj_long_query active 28s - 6343 select pg_sleep(3600);
prepared: 1
gid owner database age xid
kbdiag_inj_2pc system test 29s 6346
EXIT_CODE=1
默认阈值下,idle in transaction 超过 300 秒的会话也会被 sessions 报成 session.idle_in_txn。两条回答的问题不同。
在备库上
~/kbdiag txn
echoEXIT_CODE=$?
txn OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-09-27T13:37:20+08:00)
oldest xid: 6354 (599825 xmin)
open transactions: 1
pid user database application state xact xid xmin sql
599825 system test kbdiag_inj_lock_waiter active 14s - 6354 select pg_advisory_lock(424242);
txn.prepared: not_applicable (a standby cannot see the primary's two-phase transactions: run kbdiag txn on the primary)
EXIT_CODE=0
waits OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:34:44+08:00)
not idle: 0
not shown: 3 idle, 8 background
EXIT_CODE=0
主库忙的时候,追赶中的 walsender 可能以 IO:WALRead 之类的等待出现,属正常。
在备库上
~/kbdiag waits
echoEXIT_CODE=$?
waits OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-09-27T13:37:21+08:00)
not idle: 1
wait state sessions pids
Lock:advisory active 1 599825
not shown: 3 idle, 4 background
EXIT_CODE=0
status FAIL (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:38:16+08:00)
[FAIL] inst.connections 98 connections in use, reaching the 97 ordinary users may open (max_connections 100 minus 3 reserved for superusers): ordinary users can no longer connect
verify: kbdiag sessions # who holds the connections: the summary at the top counts them by user, database, application and client
inst.info
version V008R006C009B0014
data_directory /home/kingbase/cluster/install/kingbase/data
port 54321
start_time 2026-09-20 22:19:13 (up 6d 15h)
connections 98 / 97 (max_connections 100 - superuser_reserved 3)
inst.downstreams: 1
name address state sync
node2 192.168.105.11 streaming quorum
inst.upstream: not_applicable (primary)
inst.databases: 5, total 382 MB
test 325 MB
esrep 15 MB
mydb 14 MB
kingbase 14 MB
security 14 MB
inst.disk (filesystem of data_directory)
used 14 GB / 199 GB (7%)
free 185 GB
EXIT_CODE=2
已用 98 个,超过了 97,因为超级用户还能从保留的连接里进来,kbdiag 自己用的 system 连接也在其中。
[WARN] inst.upstream the standby has no WAL receiver and is not receiving WAL from the primary: if the primary fails now, no standby can take over
verify: kbdiag slots # run on the primary: is this standby's slot inactive?
slots OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-09-27T13:37:21+08:00)
slots: 0
EXIT_CODE=0
不活跃的槽
~/kbdiag slots
echoEXIT_CODE=$?
slots WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:37:55+08:00)
[WARN] slot.inactive replication slot repmgr_slot_2 is inactive, retaining 216 bytes WAL, xmin 6354 holding back the vacuum horizon
verify: kbdiag status # run on this slot's downstream node (usually a standby): if it cannot connect, the node is down; inst.upstream with no receiver or not streaming means it is not receiving WAL; if it shows streaming, run it again after 10-20s: a last_msg that keeps growing means the receiver is stuck
slots: 1
name type active retained xmin xmin age restart_lsn
repmgr_slot_2 physical no 216 bytes 6354 0 0/A42FF338
EXIT_CODE=1
How far each database is from transaction ID wraparound; the oldest tables of this one
Usage:
kbdiag freeze [flags]
Flags:
-h, --help help for freeze
--limit int max rows to show, 0 for all (findings still cover every row) (default 20)
Global Flags:
-d, --dbname string database to connect to (default "test")
--host string server host, or socket directory (default /tmp)
--json print the report as JSON
-p, --port int server port (default 54321)
--timeout duration statement timeout for each query (default 10s)
-U, --user string database user (password from PGPASSWORD or ~/.pgpass) (default "system")
EXIT_CODE=0
vacuum OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:20:54+08:00)
settings
autovacuum on (3 workers, naptime 1m 0s)
track_counts on
threshold 50 + 0.2 x reltuples
running: 0
tables in test: 98, most dead tuples first
table dead live threshold due autovacuum last autovacuum last vacuum
sysmac.sysmac_policy 0 0 50.2 - on never never
sysmac.sysmac_level 0 0 50.8 - on never never
sysmac.sysmac_compartment 0 0 50 - on never never
sysmac.sysmac_label 0 0 50.8 - on never never
sysmac.sysmac_policy_enforcement 0 0 50 - on never never
sysmac.sysmac_user 0 0 50 - on never never
sysmac.sysmac_obj 0 0 50 - on never never
sysmac.sysmac_column_label 0 0 50 - on never never
sys_hm.check_type 0 0 50.4 - on never never
sys_hm.hm_run_t 0 0 50 - on never never
sys_hm.check_param 0 0 50.2 - on never never
sys.dual 0 0 50.2 - on never never
sys_catalog._kingbase_loginfo 0 0 50 - on never never
public.t1 0 0 50 - on never never
public.t_perf_test 0 0 20050 - on never never
kdb_schedule.kdb_jobagent 0 0 50 - on never never
kdb_schedule.kdb_jobclass 0 0 50 - on never never
kdb_schedule.kdb_action 0 0 50 - on never never
kdb_schedule.kdb_schedule 0 0 50 - on never never
kdb_schedule.kdb_schedule_job 0 0 50 - on never never
... 78 more not shown (--limit 0 shows all)
EXIT_CODE=0
列表按死元组数排序,最上面的行都是 0,所以没有表过线。每张表的 last autovacuum never 只说明统计重置以来 autovacuum 没轮到过它们。
备库
~/kbdiag vacuum
echoEXIT_CODE=$?
vacuum OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:01+08:00)
settings
autovacuum on (3 workers, naptime 1m 0s)
track_counts on
threshold 50 + 0.2 x reltuples
running: not_applicable (standby: autovacuum does not run here; run on the primary)
tables in test: not_applicable (standby: table statistics are local to each node and stay 0 here; run on the primary)
EXIT_CODE=0
vacuum WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:12+08:00)
[WARN] vacuum.table_disabled table public.kbdiag_inj_dead has 5000 dead tuples, past its autovacuum threshold 2050, but autovacuum is off for it (autovacuum_enabled=off): nothing will clean it
fix: VACUUM public.kbdiag_inj_dead # connected to database test; turn autovacuum back on with ALTER TABLE ... RESET (autovacuum_enabled) unless it was turned off on purpose
verify: kbdiag txn # if dead tuples remain after VACUUM: the oldest transaction holding back the horizon
verify: kbdiag slots # or a replication slot's xmin
settings
autovacuum on (3 workers, naptime 1m 0s)
track_counts on
threshold 50 + 0.2 x reltuples
running: 0
tables in test: 99, most dead tuples first
table dead live threshold due autovacuum last autovacuum last vacuum
public.kbdiag_inj_dead 5000 5000 2050 yes off never never
sysmac.sysmac_policy 0 0 50.2 - on never never
sysmac.sysmac_level 0 0 50.8 - on never never
sysmac.sysmac_compartment 0 0 50 - on never never
sysmac.sysmac_label 0 0 50.8 - on never never
sysmac.sysmac_policy_enforcement 0 0 50 - on never never
sysmac.sysmac_user 0 0 50 - on never never
sysmac.sysmac_obj 0 0 50 - on never never
sysmac.sysmac_column_label 0 0 50 - on never never
sys_hm.check_type 0 0 50.4 - on never never
sys_hm.hm_run_t 0 0 50 - on never never
sys_hm.check_param 0 0 50.2 - on never never
sys.dual 0 0 50.2 - on never never
sys_catalog._kingbase_loginfo 0 0 50 - on never never
public.t1 0 0 50 - on never never
public.t_perf_test 0 0 20050 - on never never
kdb_schedule.kdb_jobagent 0 0 50 - on never never
kdb_schedule.kdb_jobclass 0 0 50 - on never never
kdb_schedule.kdb_action 0 0 50 - on never never
kdb_schedule.kdb_schedule 0 0 50 - on never never
... 79 more not shown (--limit 0 shows all)
EXIT_CODE=1
archive WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:20:55+08:00)
[WARN] archive.failing archiving is failing: the last attempt failed (0000000300000000000000A3, 6s ago) and the last success was 21d 3h ago (0000000300000000000000A2); 22590 failures since the statistics reset. WAL that is not archived stays in sys_wal and is missing from the backups
verify: kbdiag space # how big sys_wal has grown; why archive_command fails is in the server log (log_directory)
settings
archive_mode always
archive_command export TZ=Asia/Shanghai;/home/kingbase/cluster/install/kingbase/bin/sys_rman --config /rman/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p
archive_timeout 0 (off)
archiver (counting since 2026-09-15 23:12:34)
archived 35 last 0000000300000000000000A2 21d 3h ago
failed 22590 last 0000000300000000000000A3 6s ago
waiting: 38 .ready, 174 .done (oldest .ready 21d 3h)
EXIT_CODE=1
archive WARN (KingbaseES V008R006C009B0014, primary, kbdiag_ro@remote, 2026-10-07T17:21:09+08:00)
[WARN] archive.failing archiving is failing: the last attempt failed (0000000300000000000000A3, 20s ago) and the last success was 21d 3h ago (0000000300000000000000A2); 22590 failures since the statistics reset. WAL that is not archived stays in sys_wal and is missing from the backups
verify: kbdiag space # how big sys_wal has grown; why archive_command fails is in the server log (log_directory)
settings
archive_mode always
archive_command export TZ=Asia/Shanghai;/home/kingbase/cluster/install/kingbase/bin/sys_rman --config /rman/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p
archive_timeout 0 (off)
archiver (counting since 2026-09-15 23:12:34)
archived 35 last 0000000300000000000000A2 21d 3h ago
failed 22590 last 0000000300000000000000A3 20s ago
waiting: skipped (insufficient_privilege 42501: permission denied for function sys_ls_archive_statusdir)
EXIT_CODE=1
fix 是把运行值写回去:ALTER SYSTEM SET x = '<运行值>',再 SELECT sys_reload_conf()。PostgreSQL 12 的 reload 只在文件里的值等于运行值时才清掉 pending 标志,只做 ALTER SYSTEM RESET 会一直挂到下次重启。如果这个改动是有意的,就该去安排重启。
repl OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:20:56+08:00)
sync
synchronous_standby_names ANY 1( node2) (any 1 of node2 must confirm)
synchronous_commit remote_apply
synchronous now 1 (node2)
downstreams: 1 (bytes behind this node's current WAL position)
name address state sync sent flushed replayed replay lag last reply
node2 192.168.105.11 streaming quorum 0 bytes 0 bytes 0 bytes 0s 1s ago
EXIT_CODE=0
sync 显示 synchronous_standby_names 和它的含义(any 1 of node2 must confirm)、synchronous_commit,以及服务器现在把几个备库算作同步的。sync 列里的 quorum 是服务器自己的 sync_state;repmgr 下实测就是 quorum,不是 sync 或 async,所以 kbdiag 不翻译。
repl OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:03+08:00)
upstream
status streaming
upstream 192.168.105.10:54321
slot repmgr_slot_2
last_msg 3s ago
replay
received 0/C9352A80
replayed 0/C9352A80 (caught up with what was received)
last replayed transaction 1m 0s ago
paused no
downstreams: 0
EXIT_CODE=0
upstream 和 kbdiag status 里的 inst.upstream 是同一个 WAL 接收进程视图,last_msg 是离主库最后一条消息多久。
replay 对比收到的和回放的。caught up with what was received 表示两个位置相等。last replayed transaction 1m 0s ago 不是延迟:空闲的主库上它能读到好几个小时而位置完全一致,所以 kbdiag 不把它当成延迟。
paused 是回放有没有被 sys_wal_replay_pause() 暂停。
WAL 接收进程卡住
备库的接收进程被暂停后,备库上报:
~/kbdiag repl
echoEXIT_CODE=$?
repl WARN (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:22:58+08:00)
[WARN] inst.upstream the standby's WAL receiver shows streaming, but nothing has come from the primary for 1m 12s, longer than wal_receiver_timeout (30s), after which a working receiver reconnects: it is stuck (stopped or blocked), so it is not receiving WAL: if the primary fails now, no standby can take over
verify: kbdiag slots # run on the primary: is this standby's slot inactive?
upstream
status streaming
upstream 192.168.105.10:54321
slot repmgr_slot_2
last_msg 1m 12s ago
replay
received 0/CCCC9228
replayed 0/CCCC9228 (caught up with what was received)
last replayed transaction 1m 12s ago
paused no
downstreams: 0
EXIT_CODE=1
this node is node1: repmgr says primary, the database is a primary 这一行就是 repmgr 元数据和数据库自己看法的对照。attached here: node2 是 repmgr 说跟着本节点的备库里、这里真有 walsender 的那些。
cluster UNKNOWN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:11+08:00)
nodes: skipped (no repmgr schema in database test named by -d; repmgr keeps it in database esrep by default)
events: skipped (no repmgr schema in database test named by -d; repmgr keeps it in database esrep by default)
EXIT_CODE=3
rows 里估算值(reltuples)旁边是统计里的活元组和死元组。xid age 是冻结年龄,对照 autovacuum_freeze_max_age。
vacuum and analyze:死元组对照 autovacuum 触发线,最近手工和自动的 vacuum、analyze 各多久前、几次,以及上次 analyze 之后的修改数。
access since the statistics reset:扫描、读写的行数、块缓存命中,命中率保留一位小数,几次读盘不会被四舍五入成 100%。
indexes 有大小、扫描次数、是不是主键和定义。
判定复用别的命令的规则,没有新规则:年龄对照和 freeze 同样的两条线(finding id 是 freeze.table_age),表级关了 autovacuum 又过线是 vacuum.table_disabled。这里两条都没触发,所以是 OK。
同一张表在备库上
~/kbdiag table orders
echoEXIT_CODE=$?
table OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:04+08:00)
public.orders (table)
size 170 MB (heap 62 MB, indexes 108 MB, no TOAST)
rows 1000000 estimated
xid age 994 (autovacuum_freeze_max_age 200000000)
mxid age 0
reloptions -
statistics: not_applicable (standby: table statistics are local to each node and stay 0 here; run on the primary)
indexes: 3
name size scans kind definition
idx_orders_user_status 30 MB - - CREATE INDEX idx_orders_user_status ON public.orders USING btree (user_id, status)
kbdiag_rev_idx 56 MB - - CREATE INDEX kbdiag_rev_idx ON public.orders USING btree (md5((id)::text))
orders_pkey 22 MB - primary key CREATE UNIQUE INDEX orders_pkey ON public.orders USING btree (id)
EXIT_CODE=0
table WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:13+08:00)
[WARN] vacuum.table_disabled table public.kbdiag_inj_dead has 5000 dead tuples, past its autovacuum threshold 2050, but autovacuum is off for it (autovacuum_enabled=off): nothing will clean it
fix: VACUUM public.kbdiag_inj_dead # connected to database test; turn autovacuum back on with ALTER TABLE ... RESET (autovacuum_enabled) unless it was turned off on purpose
public.kbdiag_inj_dead (table)
size 712 kB (heap 704 kB, indexes 0 bytes, TOAST 8192 bytes)
rows 10000 estimated; 5000 live, 5000 dead
xid age 4 (autovacuum_freeze_max_age 200000000)
mxid age 0
reloptions autovacuum_enabled=off
vacuum and analyze
dead tuples 5000, autovacuum threshold 2050: due (autovacuum is off for this table)
last vacuum never (0 times)
last autovacuum never (0 times)
last analyze 1s ago (1 time)
last autoanalyze never (0 times)
modified since analyze 5000
access since the statistics reset
seq scans 1 (10000 rows read)
index scans -
rows written 10000 inserted, 0 updated (0 HOT), 5000 deleted
heap blocks 87 read, 15335 hit (99.4% hit)
index blocks -
indexes: 0
EXIT_CODE=1
finding 和 kbdiag vacuum 对这张表报的是同一条:vacuum.table_disabled,fix 也一样。reloptions 里能看到原因 autovacuum_enabled=off,文本写 due (autovacuum is off for this table)。
modified since analyze 是 5000,和删掉的 5000 行对得上。
过了线但 autovacuum 开着
~/kbdiag table kbdiag_inj_tbl
echoEXIT_CODE=$?
table OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:18+08:00)
public.kbdiag_inj_tbl (table)
size 2504 kB (heap 1520 kB, indexes 976 kB, TOAST 8192 bytes)
rows 20000 estimated; 15000 live, 5000 dead
xid age 5 (autovacuum_freeze_max_age 200000000)
mxid age 0
reloptions -
vacuum and analyze
dead tuples 5000, autovacuum threshold 4050: due
last vacuum never (0 times)
last autovacuum never (0 times)
last analyze 1s ago (1 time)
last autoanalyze never (0 times)
modified since analyze 5000
access since the statistics reset
seq scans 3 (20000 rows read)
index scans 0 (0 rows fetched)
rows written 20000 inserted, 0 updated (0 HOT), 5000 deleted
heap blocks 189 read, 25743 hit (99.2% hit)
index blocks 122 read, 79374 hit (99.8% hit)
indexes: 2
name size scans kind definition
kbdiag_inj_tbl_n 520 kB 0 - CREATE INDEX kbdiag_inj_tbl_n ON public.kbdiag_inj_tbl USING btree (n)
kbdiag_inj_tbl_pkey 456 kB 0 primary key CREATE UNIQUE INDEX kbdiag_inj_tbl_pkey ON public.kbdiag_inj_tbl USING btree (id)
EXIT_CODE=0
kbdiag: no table "no_such_table" in database "test" (unquoted names fold to lower case; quote them as in SQL: '"Name"'; use -d for another database)
table UNKNOWN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:19+08:00)
table: not found
EXIT_CODE=3
第一行是 stderr,说明不带引号的名字会折成小写,以及用 -d 选别的库。退出码 3(UNKNOWN),报告正文只有 table: not found。
top UNKNOWN (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:20:58+08:00)
statements: skipped (sys_stat_statements.track=none: statements are not being collected; set it to top or all)
EXIT_CODE=3
skipped 并写明原因,结论是 UNKNOWN:空表加 OK 等于说“没有昂贵的 SQL”,而实际上什么都没测。备库(kes-node2)上打印的一样。
progress OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:20:58+08:00)
running: 0 (VACUUM, CREATE INDEX, CLUSTER and VACUUM FULL, CHECKPOINT; ANALYZE and base backups have no progress view in this version)
EXIT_CODE=0
文本写明了它看哪几种操作,也写明了看不到什么:这个版本没有 ANALYZE 和 base backup 的进度视图。备库(kes-node2)上打印的是同一行。
checkpoint OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:06+08:00)
checkpoint record the last restartpoint started from (written by the primary)
time 2026-10-07 17:18:33 (2m 33s ago)
redo 0/C651C548 (0000000300000000000000C6)
since the statistics reset 2026-10-07 16:49:26 (31m 40s ago)
checkpoints 43 timed, 0 requested restartpoint attempts (a standby counts every try, one every 15s while no new checkpoint record has arrived)
write, sync time 2m 51s, 26 ms
buffers written 45117: checkpointer 7496 (17%), bgwriter 0 (0%), backends and others 37621 (83%)
buffers allocated 38458
backend fsyncs 1
bgwriter stopped 0 times at bgwriter_lru_maxpages
settings
checkpoint_timeout 5m 0s
max_wal_size 1024 MB
checkpoint_completion_target 0.5
checkpoint_warning 30s
log_checkpoints on
EXIT_CODE=0
seq OK (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:00+08:00)
sequences in test: 16, most used first
sequence type last limit used left
public.kbdiag_test_id_seq integer 1311000 2147483647 0.06% 2.15e+09
kdb_schedule.kdb_jobclass_jclid_seq integer 5 2147483647 0.00% 2.15e+09
perf.kwr_snapshots_snap_id_seq integer 2 2147483647 0.00% 2.15e+09
public.flight_psg_new_info_id_seq bigint 1000000 9223372036854775807 0.00% 9.22e+18
public.orders_id_seq bigint 1000000 9223372036854775807 0.00% 9.22e+18
public.t_perf_test_id_seq bigint 100000 9223372036854775807 0.00% 9.22e+18
sysmac.sysmac_policy_oid_seq bigint 1 9223372036854775807 0.00% 9.22e+18
kdb_schedule.kdb_action_acid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_exception_jexid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_job_action_jaid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_joblog_jlgid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_jobsteplog_jslid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_job_sjid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_scid_seq integer - 2147483647 - no value yet
sys_catalog.global_chain_seq bigint - 9223372036854775807 - no value yet
sys_hm.hm_run_t_run_id_seq integer - 2147483647 - no value yet
EXIT_CODE=0
seq OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:07+08:00)
sequences in test: 16, most used first
on a standby a sequence reads up to 32 values ahead of the primary (and is not judged): run on the primary
sequence type last limit used left
public.kbdiag_test_id_seq integer 1311029 2147483647 0.06% 2.15e+09
kdb_schedule.kdb_jobclass_jclid_seq integer 33 2147483647 0.00% 2.15e+09
perf.kwr_snapshots_snap_id_seq integer 33 2147483647 0.00% 2.15e+09
public.flight_psg_new_info_id_seq bigint 1000032 9223372036854775807 0.00% 9.22e+18
public.orders_id_seq bigint 1000032 9223372036854775807 0.00% 9.22e+18
public.t_perf_test_id_seq bigint 100023 9223372036854775807 0.00% 9.22e+18
sysmac.sysmac_policy_oid_seq bigint 1 9223372036854775807 0.00% 9.22e+18
kdb_schedule.kdb_action_acid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_exception_jexid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_job_action_jaid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_joblog_jlgid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_jobsteplog_jslid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_job_sjid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_scid_seq integer - 2147483647 - no value yet
sys_catalog.global_chain_seq bigint - 9223372036854775807 - no value yet
sys_hm.hm_run_t_run_id_seq integer - 2147483647 - no value yet
EXIT_CODE=0
备库上的序列值是 WAL 里的副本,主库每次预写 32 个,所以备库可能读到“到头了”而主库还有值。文本说明了这点(up to 32 values ahead of the primary),备库不判:要到主库上跑 seq。上面的 last 确实比主库的大。
seq UNKNOWN (KingbaseES V008R006C009B0014, primary, kbdiag_ro@remote, 2026-10-07T17:21:08+08:00)
sequences in test: 16, most used first
sequence type last limit used left
kdb_schedule.kdb_action_acid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_exception_jexid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_job_action_jaid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_jobclass_jclid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_joblog_jlgid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_jobsteplog_jslid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_schedule_job_sjid_seq integer ? 2147483647 ? ?
kdb_schedule.kdb_schedule_scid_seq integer ? 2147483647 ? ?
perf.kwr_snapshots_snap_id_seq integer ? 2147483647 ? ?
public.flight_psg_new_info_id_seq bigint ? 9223372036854775807 ? ?
public.kbdiag_test_id_seq integer ? 2147483647 ? ?
public.orders_id_seq bigint ? 9223372036854775807 ? ?
public.t_perf_test_id_seq bigint ? 9223372036854775807 ? ?
sys_catalog.global_chain_seq bigint - 9223372036854775807 - no value yet
sys_hm.hm_run_t_run_id_seq integer - 2147483647 - no value yet
sysmac.sysmac_policy_oid_seq bigint ? 9223372036854775807 ? ?
redacted: 14 rows of seq.list hide last_value (insufficient_privilege; grant SELECT on the sequences (sys_monitor does not cover them))
EXIT_CODE=3
? 是这个账号读不了的 last_value(序列上没有 SELECT 权限),所以 used 和 left 算不出。SQL 按 oid 判权限,序列中途被删掉不会让整条 probe 失败。14 个看不到的行记在 redacted 里,提示给序列授予 SELECT:sys_monitor 不覆盖序列。
值是 - 的两行是从没调用过的序列(no value yet):它和权限不够造成的 NULL 不是一回事,kbdiag 把两者分开。
结论是 UNKNOWN,因为没能看到这些值。
用完的序列
~/kbdiag seq
echoEXIT_CODE=$?
seq FAIL (KingbaseES V008R006C009B0014, primary, system@local, 2026-10-07T17:21:20+08:00)
[FAIL] seq.exhausted sequence public.kbdiag_inj_seq (integer) is at 3, its limit is 3: nextval fails, so inserts that use it fail
fix: ALTER SEQUENCE public.kbdiag_inj_seq MAXVALUE <higher> # it stops at its MAXVALUE, short of what its type allows
sequences in test: 17, most used first
sequence type last limit used left
public.kbdiag_inj_seq integer 3 3 100.00% 0
public.kbdiag_test_id_seq integer 1311000 2147483647 0.06% 2.15e+09
kdb_schedule.kdb_jobclass_jclid_seq integer 5 2147483647 0.00% 2.15e+09
perf.kwr_snapshots_snap_id_seq integer 2 2147483647 0.00% 2.15e+09
public.flight_psg_new_info_id_seq bigint 1000000 9223372036854775807 0.00% 9.22e+18
public.orders_id_seq bigint 1000000 9223372036854775807 0.00% 9.22e+18
public.t_perf_test_id_seq bigint 100000 9223372036854775807 0.00% 9.22e+18
sysmac.sysmac_policy_oid_seq bigint 1 9223372036854775807 0.00% 9.22e+18
kdb_schedule.kdb_action_acid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_exception_jexid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_job_action_jaid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_joblog_jlgid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_jobsteplog_jslid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_job_sjid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_scid_seq integer - 2147483647 - no value yet
sys_catalog.global_chain_seq bigint - 9223372036854775807 - no value yet
sys_hm.hm_run_t_run_id_seq integer - 2147483647 - no value yet
EXIT_CODE=2
seq OK (KingbaseES V008R006C009B0014, standby, system@local, 2026-10-07T17:21:21+08:00)
sequences in test: 17, most used first
on a standby a sequence reads up to 32 values ahead of the primary (and is not judged): run on the primary
sequence type last limit used left
public.kbdiag_inj_seq integer 3 3 100.00% 0
public.kbdiag_test_id_seq integer 1311029 2147483647 0.06% 2.15e+09
kdb_schedule.kdb_jobclass_jclid_seq integer 33 2147483647 0.00% 2.15e+09
perf.kwr_snapshots_snap_id_seq integer 33 2147483647 0.00% 2.15e+09
public.flight_psg_new_info_id_seq bigint 1000032 9223372036854775807 0.00% 9.22e+18
public.orders_id_seq bigint 1000032 9223372036854775807 0.00% 9.22e+18
public.t_perf_test_id_seq bigint 100023 9223372036854775807 0.00% 9.22e+18
sysmac.sysmac_policy_oid_seq bigint 1 9223372036854775807 0.00% 9.22e+18
kdb_schedule.kdb_action_acid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_exception_jexid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_job_action_jaid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_joblog_jlgid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_jobsteplog_jslid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_job_sjid_seq integer - 2147483647 - no value yet
kdb_schedule.kdb_schedule_scid_seq integer - 2147483647 - no value yet
sys_catalog.global_chain_seq bigint - 9223372036854775807 - no value yet
sys_hm.hm_run_t_run_id_seq integer - 2147483647 - no value yet
EXIT_CODE=0