feat(cli): add inspect db xid-age command - #6527
Open
bruno222 wants to merge 4 commits into
Open
Conversation
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>
Contributor
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@1aa9d9ca5d1b57550f6ccc0223871673df250c0cPreview package for commit |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
xid-ageunderinspect db(3 files: query, handler, command)db.command.tsapps/cli/docs/supabase/inspect/db-xid-age.mdinspect-specs.integration.test.tsSIDE_EFFECTS.mdupdatedWhy 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 tosupabase/supabase.