Skip to content

Isolate compact job persistence from settlement locking - #456

Merged
djh58 merged 1 commit into
3.x.xfrom
djh58/prism-b275-lock-isolation
Sep 18, 2026
Merged

djh58 merged 1 commit into
3.x.xfrom
djh58/prism-b275-lock-isolation

Conversation

@djh58

@djh58 djh58 commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Compact issued jobs currently wait behind unrelated settlement advisory holders, including the missing-dependency repair path. This change lets compact singleton, batch, repair, and direct prepared persistence complete under a held settlement stub while retaining the cluster authority fence through commit.

The collector joins that protocol with SETTLEMENT → ORDER → cluster FOR UPDATE → fresh reference scans. Writers retain cluster FOR SHARE before revision, writable-state, and configuration checks; direct prepared storage moves those checks behind the fence. This protects surviving orphan blobs during repair and preserves candidate references, retention renewal, exact retries, atomic cohorts, original deadlines, and unknown-commit/cancellation ownership.

Upgrade requirement: stop all frontends and collectors, upgrade them together, then restart. An old collector is unsafe with a new unlocked repair writer. Schema and compact format 1 are unchanged; arbitrary rolling compatibility is unsupported.

Part of #275. Fresh publication still performs chain-observation locking, and this PR makes no full-refresh or one-second/2,000-session performance claim. Historical measurement reports remain unchanged.

Validation (disposable PostgreSQL 16, two build jobs / Tokio workers):

  • Focused persistence/runtime/epoch suite: 103 passed; all 79 expected database gates executed.
  • Server unit suite: 468 passed, including the existing original-deadline, repair-authority, readiness, lease, and cancellation regressions; two existing full-size experiments ignored.
  • Eight actual Coordinator stub cases prove return and exact durable rows before controlled three-second release, covering one/two frontends, singleton/64-request cohorts, and surviving/missing-blob repair. The direct batch API additionally proves all 64 children share one transaction under the stub.
  • Ordinary revision/fatal/config updates in both orders; actual chain transition and stale ABA epoch; orphan-repair/GC in both orders with candidate references; renewal/delete; concurrent exact retry and whole-batch conflict rollback; unchanged runtime unknown-COMMIT/publication regressions.
  • Broader authority suite: 234 passed; lifecycle/deadline/authorization: 73 passed; seven explicitly enabled legacy dependency contracts passed. Total: 885 passed, with five existing opt-in performance experiments left ignored.
  • cargo clippy --locked --workspace --all-targets -- -D warnings passed.

Test commands used test/prism-native-tests.sh cargo-args --locked -p qbit-prism-server with --test-threads=1 --nocapture, selecting:

--lib
--test b275_persistence_measure --test chain_epoch_migration --test compact_issued_batch --test compact_issued_repair --test compact_prepared_storage --test compact_runtime_e2e
--test candidate_window_switch --test equal_work_scheduler --test equal_work_tip --test ledger_postgres --test lost_race_pin --test window_reference
--test authorization_rpc --test ledger_deadline_atomicity --test ledger_single_execution --test readiness_rpc --test refresh_liveness
--test issued_job_dependency  (with --ignored)

All 436 expected database gates for those selected targets executed. Full workspace formatting, gate-input lint, and diff whitespace checks passed.

No version or changelog changes. Independent review is requested for the lock protocol and supported upgrade boundary.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Retain cluster SHARE before all compact persistence authority checks and
join blob collection to the same protocol with an exclusive cluster fence
after SETTLEMENT and ORDER, before fresh reference scans.

Prove runtime and direct persistence under a held settlement stub, preserve
authority/expiry/cancellation assertions at the true row fence, and cover
surviving orphan repair races in both collector orders. Require coordinated
stop-all upgrades because old collectors cannot fence the new writers.

Part of #275; the full refresh performance target remains open.
@djh58

djh58 commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

@cursor review

@djh58

djh58 commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Independent review started against f5dba64: native medium code review, structural/thermo review, independent Fable adversarial review, and separate Codex Sol adversarial review. Cursor review is also requested. All 19 CI jobs are green on this head; review findings and their dispositions will be posted before a merge-ready recommendation. This is a progress record, not a completed review ledger.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f5dba64. Configure here.

@djh58

djh58 commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Final review closeout — f5dba64

Merge recommendation: ready for 3.x.x. All 19 CI checks and Cursor Bugbot pass; no unresolved inline review comments were present at closeout. This is not a deployment or full #275 performance acceptance approval.

Independent lanes completed against base 587aef599611319400c28369501a89d0cae120b8:

  • Native medium code review: no required defect. This was a native medium review, not an invocation of the unavailable /code-review plugin.
  • Structural/thermo: no required correctness, durability, authority or availability defect.
  • Fable adversarial: no refutation found.
  • Codex Sol adversarial: no refutation found.

The lanes independently traced writer/collector ordering, surviving-orphan repair in both orders, revision/fatal/config fencing, atomic cohorts, cancellation and unknown commit. Their evidence is source analysis; none independently reran PostgreSQL tests. Execution evidence comes from the author's qualification and the green hosted PostgreSQL shards and gate-manifest check, not fabricated reviewer test runs.

Dispositions

Zero required defects remain. Under the approved risk-proportionate review policy, these optional observations do not require another fix round:

  • Repeated authority-fence prologues and repeated test helpers/narrative: optional consolidation declined for this change. The three implementations were checked for consistent ordering; refactoring would create a new lock-sensitive delta without repairing an identified defect.
  • Untimed cluster-row waits: accepted measurement boundary, not claimed zero contention. The operations guide explicitly distinguishes row waits from settlement advisory time; no repository alert was found to depend on this series measuring those writers. A new metric family is not added here.
  • Startup configuration can wait behind a collector sweep: accepted bounded contention consequence of the stronger collector fence, not a claim of contention-free startup.
  • Unsupported mixed versions: stop all frontends and collectors before replacing them. Old collector/new writer is unsafe; no rolling-upgrade or runtime-version-guard guarantee is claimed.
  • Transaction isolation: the fresh-snapshot reasoning assumes PostgreSQL's default READ COMMITTED. A database/session override to REPEATABLE READ is not qualified by this PR; the adversarial lane identified that existing configuration assumption, not evidence of safety under arbitrary isolation overrides.
  • Optional test/document polish (named advisory constant, fuller share-append lock-table notation, fixture-local blob deletion, helper extraction and test-file organization): declined as nonblocking polish. Existing blob-row locks remain intact.

No additional production change is requested by this closeout. #275 stays open for delivery-scale and two-frontend qualification; this PR does not establish the one-second full-refresh target or an ARM-specific speedup.

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