Skip to content

Allow native storage cuts during parent analysis - #687

Draft
fazpu wants to merge 1 commit into
mainfrom
fix/native-capture-parent-analysis
Draft

fazpu wants to merge 1 commit into
mainfrom
fix/native-capture-parent-analysis

Conversation

@fazpu

@fazpu fazpu commented Nov 28, 2026

Copy link
Copy Markdown
Member

Problem

A managed sweeper runs ANALYZE ONLY on partitioned parents. PostgreSQL takes SHARE UPDATE EXCLUSIVE during that statement. The native collector can miss the original UTC cut when its parent-level SHARE NOWAIT conflicts with analysis that started first. A missed cut can leave a billing period unmeasured. Managed sweeper change

Change

  • Take ACCESS SHARE on storage-less partitioned parents. Keep the original heap, TOAST and physical index exclusions.
  • Fence catalog topology writes with SHARE on pg_inherits. Check the same guard transaction after the cut for a topology change that had already been written before the lock and subsequently committed. Refuse a pending concurrent detach. This preserves the D152 requirement that sampled allocations and the original view refer to the same partition tree. D152 native capture
  • Let the existing bounded lock timeout cover a transient pg_class lock during analysis. The sweeper's bounded analysis can yield at pg_class when the collector arrives first. PostgreSQL 18.6 analysis · Statistics catalog update · Inheritance catalog (checked 2026-11-28)
  • Advertise rememberstack.partition_parent_analyze_compatible=on in the installed guard definition. Managed Projects can enable parent analysis as each database's compatible guard is installed through regular provisioning or upgrade.

Verification

  • Ruff format, Ruff check, and Pyright passed.
  • PostgreSQL 18.6 native guard and original-view suites passed (17 tests). The regression exercises ANALYZE ONLY public.mentions in both acquisition orders with an ordinary collector login, a timeout while the guard holds, and a separate attachment committed during the cut. Existing guard coverage exercises allocation reconciliation, physical writers, BM25 and TOAST.
  • Managed rollout needs a released engine pin and installation of the guard in the Project databases. The managed branch allows parent analysis only after that installation.

Contributor agreement

Signing on behalf of a legal entity (leave blank if accepting individually):

Pin storage-less parents with ACCESS SHARE. Fence inheritance catalog
writes and recheck the original topology after the cut to detect a
commit that had already written its catalog entries. Keep the physical
heap, TOAST and index locks through the cut.

Advertise compatibility in the installed definition so the managed
sweeper can check each Project database before analyzing its parents.
Exercise both acquisition orders and an in-flight partition attachment
using the ordinary collector against PostgreSQL 18.6.

Co-Authored-By: GPT 6.2 sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq

This branch has not been deployed

No deployments
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