Skip to content

feat(cli): add inspect db xid-age command - #6527

Open
bruno222 wants to merge 4 commits into
developfrom
feat/inspect-db-xid-age
Open

feat(cli): add inspect db xid-age command#6527
bruno222 wants to merge 4 commits into
developfrom
feat/inspect-db-xid-age

Conversation

@bruno222

@bruno222 bruno222 commented Sep 8, 2026

Copy link
Copy Markdown

Summary

Adds supabase inspect db xid-age — a new Disk Storage Analysis command that lists all user tables sorted by their transaction ID (XID) age, from oldest to newest.

What changed

  • New subcommand xid-age under inspect db (3 files: query, handler, command)
  • Registered in db.command.ts
  • Docs overlay at apps/cli/docs/supabase/inspect/db-xid-age.md
  • Integration test case added to inspect-specs.integration.test.ts
  • SIDE_EFFECTS.md updated

Why it matters

PostgreSQL wraps around at ~2 billion transactions. As a table's XID age approaches that limit, PostgreSQL forces an emergency autovacuum freeze that can make the database temporarily unavailable and cannot be deferred. Tables older than 1.5 billion transactions (fewer than 500 million remaining) should be treated as urgent.

This command surfaces that risk sorted by severity, enabling operators to act before an emergency occurs. It is one of the most commonly checked metrics in database performance reviews.

Testing

  • pnpm run check:all
  • pnpm run test:unit
  • pnpm run test:integration

Docs

CLI reference page auto-generated via bun run docs:spec (committed). Guide page update (supabase.com/docs/guides/observability/inspect) to follow as a separate PR to supabase/supabase.

Adds `supabase inspect db xid-age`, which lists all user tables sorted
by their transaction ID (XID) age from oldest to newest.

PostgreSQL wraps around at ~2 billion transactions. As a table's XID age
approaches that limit, an emergency autovacuum freeze is forced — an
operation that can make the database temporarily unavailable. Tables
older than 1.5 billion transactions (fewer than 500 million remaining)
should be treated as urgent and vacuumed manually or via tuned autovacuum.

The query reads pg_class.relfrozenxid and pg_namespace, filters out
internal Supabase schemas via the shared INTERNAL_SCHEMAS parameter,
and returns the table name, current XID age, and transactions remaining.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bruno222
bruno222 requested a review from a team as a code owner September 8, 2026 20:01
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@1aa9d9ca5d1b57550f6ccc0223871673df250c0c

Preview package for commit 1aa9d9c.

bruno222 and others added 3 commits September 8, 2026 22:24
Adds xid_age to REPORT_QUERIES so `supabase inspect report --db-url`
includes the XID age data in its CSV output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant