Skip to content

fix: skip ProcessUtility hook in databases without the extension (whole-DB ANALYZE) - #3

Merged
wezell merged 2 commits into
dotcms-0.2.0from
fix/analyze-hook-without-extension
Aug 21, 2026
Merged

fix: skip ProcessUtility hook in databases without the extension (whole-DB ANALYZE)#3
wezell merged 2 commits into
dotcms-0.2.0from
fix/analyze-hook-without-extension

Conversation

@wezell

@wezell wezell commented Aug 21, 2026

Copy link
Copy Markdown
Member

Problem

On the OVH cluster (pg_deltax in shared_preload_libraries), a whole-database ANALYZE; fails in every database that never ran CREATE EXTENSION pg_deltax — i.e. all 40+ dotCMS tenant DBs:

$ psql -d dot-dotcms-corp-headless-auth -c 'ANALYZE;'
ERROR:  relation "deltax.deltax_partition" does not exist
QUERY:  SELECT schema_name, table_name FROM deltax.deltax_partition WHERE is_compressed = true

Per-table ANALYZE public.foo; works; only the rels = NIL (whole-DB) form breaks.

Root cause

restore_compressed_partition_stats() (src/copy.rs) runs after a whole-DB VACUUM/ANALYZE and queries deltax.deltax_partition unconditionally. dotcms-0.2.0 guards the DDL path only — lookup_target() in src/ddl.rs (307bf31, issue xataio#24 follow-up) — so ALTER TABLE is safe but the vacuum path is not.

Upstream fixed this generally in xataio#25 by bailing out at the top of the ProcessUtility hook. That commit is not an ancestor of dotcms-0.2.0.

Fix

Cherry-pick upstream 8ff22d4 (xataio#25) verbatim:

  • catalog::catalog_present() — two syscache lookups (get_namespace_oid(missing_ok) + get_relname_relid), no SPI.
  • deltax_process_utility() bails to chain_to_prev() when it returns false, before restore_stats_after_vacuum is computed — so it covers both restore_compressed_partition_stats() call sites and every other interception path (COPY, RENAME, GRANT, ALTER SCHEMA).
  • tests/test_no_extension_db.py — 4 regression tests, including test_vacuum_analyze_without_extension, which exercises exactly the failing ANALYZE (rels = NIL) form.

Syscache lookups do no schema-ACL check, so this also sidesteps the permission denied for schema deltax failure mode that forced 307bf31 (tenant roles lacking USAGE on a deltax schema inherited from template1).

src/ddl.rs's existing guard is left in place — now redundant, but harmless and out of scope.

Verification

  • Cherry-pick applied clean (no conflicts).
  • cargo fmt -- --check clean.
  • get_namespace_oid / get_relname_relid are already used on this branch (src/scan/hook.rs, src/scan/cost.rs, src/scan/exec/segments.rs) with the same pgrx 0.17 signatures.
  • tests/conftest.py on this branch exports every symbol the new test imports (HOST_PORT, PG_USER, PG_PASSWORD, _admin_conn, pg_container).

Next steps (not done here)

  1. Merge → tag v0.2.0-dotcms.6 on the merge commit → release.yml builds the 4 .debs.
  2. In ovh-k8s-cluster, bump ARG PG_DELTAX_VERSION in postgres-cnpg/Dockerfile — its validate check races the fork release, so re-run it once the assets exist.
  3. Roll postgres-ovh-east by patching the live Cluster imageName to the new digest.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XGCecJYCz8dMTNPadEbeRf

tsg and others added 2 commits August 21, 2026 12:28
packaging.mk requires Cargo.toml version == git tag.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGCecJYCz8dMTNPadEbeRf
@wezell
wezell merged commit b3280fe into dotcms-0.2.0 Aug 21, 2026
6 checks passed
@wezell
wezell deleted the fix/analyze-hook-without-extension branch August 21, 2026 16:40
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.

2 participants