freeze: wraparound distance
Captured on 2026-10-07 (UTC+08) on a local KingbaseES V008R006C009B0014 primary and standby, database test, using ~/kbdiag built from Go source commit 96c874f (static linux/amd64 binary). This is lab evidence, not production validation. Both nodes were healthy and nothing was injected, so every example is OK. The WARN and FAIL cases were not produced in the lab (see the last section). Values belong to this capture only.
Usage
| Option | Effect |
|---|---|
--limit N | Show at most N tables; default 20, 0 for all |
--json | Print JSON |
Connection options are the same as for sessions. --limit only trims the table list; the findings always cover every database and every table.
Healthy primary
limitsshows the two lines kbdiag compares against, both taken from the server:autovacuum_freeze_max_age(WARN line: autovacuum must start freezing by force here) and the stop limit (FAIL line: the server refuses to hand out new transaction IDs, so write transactions fail). The stop limit is a constant of the PG12 kernel, 1 million xids before the wraparound point (2^31 - 1); for multixacts it is 100. kbdiag does not invent a threshold of its own.databasesis one row per database:xid ageandmxid ageare the age of its oldest unfrozen xid and multixact,of freeze maxis the xid age as a percentage ofautovacuum_freeze_max_age, andxids leftis how many more transaction IDs can be handed out before the stop limit.- The verdict is judged per database. A database is as old as its oldest table, so reporting every table would repeat one problem dozens of times.
tablesis shown only for the database you are connected to, oldest first; usekbdiag -d <database> freezefor another one. heap (est.)isrelpages x block_size, an estimate. The exact size functions take a lock on every table, and during a rescue (VACUUM FULL, TRUNCATE are common then) they would make the whole probe wait untillock_timeoutand fail.- Tables whose
relfrozenxidis 0 (such as_kingbase_loginfo) are left out:age(0)reads as 2147483647 and would raise a false FAIL. - On the standby the ages are replicated and equal the primary’s (the captured output on kes-node2 shows the same 5672 for every database). A VACUUM to fix a finding must still be run on the primary.
Options as the binary prints them:
WARN and FAIL: not produced in the lab
Neither finding was produced, because it would take pushing the transaction counter to hundreds of millions of xids. Taken from the source, not captured, both with the id freeze.database_age (and freeze.table_age on kbdiag table):
- WARN: a database’s xid age is at or above
autovacuum_freeze_max_age, or its multixact age is at or aboveautovacuum_multixact_freeze_max_age. The anti-wraparound autovacuum is due or cannot finish. - FAIL: the xid age is within 1 million of wraparound (or the multixact age within 100). The server refuses new transaction IDs, so writes fail.
- Next steps point to
kbdiag txnandkbdiag slots(what holds the horizon back), tokbdiag -d <database> freezefor the other databases, and toVACUUM (FREEZE)run on the primary. - If the limits could not be read, a FAIL can still be judged (the stop limit is a constant); below it the verdict is UNKNOWN.
Exit codes
| Code | Meaning |
|---|---|
| 0 | OK |
| 1 | WARN: past autovacuum_freeze_max_age (not produced in the lab) |
| 2 | FAIL: at the stop limit (not produced in the lab) |
| 3 | UNKNOWN: data not collected or not visible |
| 64 | Usage error |
| 69 | Cannot connect |