Skip to content

Add pg_durable compaction adapter - #476

Draft
tjgreen42 wants to merge 7 commits into
background-compaction-3-dispatchfrom
background-compaction-4-pg-durable
Draft

Add pg_durable compaction adapter#476
tjgreen42 wants to merge 7 commits into
background-compaction-3-dispatchfrom
background-compaction-4-pg-durable

Conversation

@tjgreen42

@tjgreen42 tjgreen42 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add an optional pg_durable adapter for per-index background compaction
requests. The adapter keeps pg_textsearch's core dispatch scheduler-neutral
while providing hardened operator scripts for deployments that use
pg_durable.

Design

  • 01_setup_role.sql creates and validates a least-privilege compactor role
    without changing state when required pg_durable capabilities are absent or
    drifted.
  • 02_wrapper.sql installs a SECURITY DEFINER request wrapper with a fixed
    search path, explicit target validation, and owner-only helper privileges.
  • Each BM25 index is submitted to its own pg_durable loop. pg_textsearch owns
    the per-index identity and stale-target bookkeeping rather than requiring a
    keyed scheduling API upstream.
  • Physical identity helpers bind work to the intended database, index OID,
    relfilenode, and creation identity so a stale job cannot compact a
    replacement relation.
  • Each loop calls bm25_compact_step() in separate transactions and uses the
    failure policy supplied by pg_durable's seven-argument df.start.
  • Fresh-install and upgrade SQL revoke extension-private helper access from
    nonowners using explicitly qualified catalog operators.

The scripts fail closed on hostile or drifted managed objects, authenticate
extension-owned pg_durable entry points, and keep the callback handoff free of
privilege escalation or stale-object reuse.

Merge blocker

Do not merge until microsoft/pg_durable#354 lands in a release. Released
pg_durable v0.2.6 and current main do not provide failure-resilient recurrence.
PR #354 targets v0.2.7 and adds the required on_failure => continue policy
through the seven-argument df.start; this adapter deliberately does not
invent a new df.loop API. The localized capability checks must gain the
released version floor once that release is available.

Test coverage

The static harness verifies wrapper identity, body hashes, extension
ownership, privilege boundaries, callback wiring, and package contents. The
live adapter harness covers transaction callbacks, precise skipping against
v0.2.6 with no side effects, and full execution against the pg_durable #354
implementation.

Stack position

This is the fourth layer of GitHub stack #479 and remains a draft because of
the upstream release blocker. It builds on #477's scheduler-neutral dispatch;
the final layer adds the singleton recovery backstop and operational
packaging.

@tjgreen42
tjgreen42 changed the base branch from background-compaction-2-api to background-compaction-3-dispatch August 29, 2026 03:40
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from 2f4324c to 04594fa Compare August 29, 2026 03:44
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch 2 times, most recently from 2963fd2 to 1478422 Compare August 29, 2026 04:38
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from 1478422 to 7c0516a Compare August 30, 2026 05:27
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from 7c0516a to 760e9d9 Compare August 30, 2026 06:10
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.38983% with 57 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/access/compaction.c 3.38% 57 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from 760e9d9 to a1b340c Compare August 30, 2026 06:20
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from a1b340c to ec88da1 Compare August 31, 2026 01:41
@tjgreen42
tjgreen42 force-pushed the background-compaction-4-pg-durable branch from ec88da1 to 063744a Compare August 31, 2026 03:20
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