Repository navigation
fix(database): allow PostgreSQL reads during anchor writes - #175389
Conversation
Existing-only opens validate the immutable anchor without BEGIN IMMEDIATE. Creation retains its transaction and all identity, schema, and admission refusals remain. A real two-handle cold-admission regression fails before the fix even with #175295 reversed. Native PostgreSQL schema and Gateway tests pass 18/18 on the refreshed base (187.50s command wall; regression 344ms), plus retained opener proof 4/4. Targeted types, core/boundary lint, format, and P2 review pass.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR validates existing PostgreSQL anchors without acquiring a SQLite writer lock while preserving transactional anchor creation. Example: A cold PostgreSQL reader opens an existing anchor while another SQLite handle holds BEGIN IMMEDIATE.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a concrete lock-contention defect still present on current main. No introduced correctness or security defect was found; CI remains unresolved. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared database-engine opener receives a store schema, engine configuration, and local SQLite anchor, then returns an admitted SQLite or PostgreSQL connection to state, agent, and plugin owners. flowchart TD
A[Store owner] --> B[Shared engine opener]
B --> C[Existing anchor validation]
B --> D[Transactional anchor creation]
C --> E[PostgreSQL admission]
D --> E
E --> F[Store queries]
Technical reviewBest possible solution: Use the existing opener's read-only anchor validation for existing-only admission and retain its transaction for creation. Do we have a high-confidence way to reproduce the issue? The main-source path requests a conflicting writer lock during existing-only admission, and the supplied regression establishes the corresponding two-handle trigger; the PR reports before/after execution, which this read-only review did not independently run. Is this the best way to solve the issue? The change repairs the shared admission owner directly, preserves all existing validation, and avoids retries, timeout increases, or a competing opening path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 354a9cc009c8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +3, Tests +37. Total +40 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 17, 2026, 5:50 AM ET / 09:50 UTC. |
…175389) Existing-only opens validate the immutable anchor without BEGIN IMMEDIATE. Creation retains its transaction and all identity, schema, and admission refusals remain. A real two-handle cold-admission regression fails before the fix even with openclaw#175295 reversed. Native PostgreSQL schema and Gateway tests pass 18/18 on the refreshed base (187.50s command wall; regression 344ms), plus retained opener proof 4/4. Targeted types, core/boundary lint, format, and P2 review pass.
What Problem This Solves
Fixes PostgreSQL-backed Gateway reads failing with
database is lockedwhen cold anchor admission overlaps another writer.User Impact
Existing PostgreSQL stores can open for reads while another handle holds write admission. Anchor creation remains transactional; missing or malformed anchors, schema drift, identity mismatches, and revoked authority keep their existing refusals. No migration, configuration change, or timeout increase is required.
Why This Change Was Made
Existing-only opens reused the anchor-creation path and unnecessarily requested
BEGIN IMMEDIATEbefore reading an immutable identity. The opener now runs the same validation without that writer transaction for existing-only admission. The new regression uses a real PostgreSQL store and two SQLite handles with cold admission and a held writer lock.This follows main hourly 39017848352. The original Gateway file passes on both main and a local reversal of #175295; the unforced CI timing has not been reproduced locally. The controlled regression fails at
BEGIN IMMEDIATEeven with #175295 reversed. That lock-taking path dates to #169933. This repairs the demonstrated owner defect without claiming a recent commit conclusively caused the CI timing.The related publication/queue failure is fixed by landed commit 598e446.
Evidence
BEGIN IMMEDIATE, including with fix(state): retain schema and disposal refusals during cold admission #175295 reversed (27.47 s command wall).--maxWorkers=1, 187.50 s command wall); new regression 344 ms. Retained opener proof adds 4/4 tests. Earlier complete three-file run: 22/22, 75.33 s.--maxWorkers=1, 198.16 s command wall). During investigation all 22 helper consumers passed, 337 tests in 537.12 s; the helper repair itself is already on main.No assertions were weakened, cases removed, retries added, or timeouts changed. The production diff extracts the existing validation body and selects its non-writing path for existing-only admission; no new owner, API, imports, schema, dependency, or configuration. PR CI supplies broad proof.