Skip to content

fix(palace): postgres backend is a multi-process-writer backend - #398

Merged
jphein merged 1 commit into
mainfrom
fix/postgres-multiprocess-writer
Aug 10, 2026
Merged

fix(palace): postgres backend is a multi-process-writer backend#398
jphein merged 1 commit into
mainfrom
fix/postgres-multiprocess-writer

Conversation

@jphein

@jphein jphein commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Post-sync production regression, caught in the wrap-up sweep: upstream v3.7's process-lifetime MCP writer lease (_acquire_mcp_writer_lock) exempts only {pgvector, qdrant} via _MULTI_PROCESS_WRITER_BACKENDS. The fork's postgres backend wasn't in the list, so the daemon's embedded MCP server took the lease at startup — and every mempalace mine subprocess the daemon spawns for POST /mine self-refused with palace … is held by PID <daemon> (main.py). 45 refused transcript ingests in hook.log since the 3.7.0 deploy.

postgres coordinates concurrent clients server-side — exactly the documented opt-out condition (same as pgvector). One-word fix + regression assertion in the existing ownership test.

Test plan

  • tests/test_palace.py extended: backend_requires_single_writer('postgres') is False
  • test_palace.py + test_mcp_server.py suites green locally
  • Post-merge: deploy to familiar, verify a real POST /mine returns returncode 0 and hook.log refusals stop

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved PostgreSQL backend behavior for multi-process write access.
    • PostgreSQL no longer requires exclusive single-writer ownership for the lifetime of a process.

Post-v3.7.0-sync production regression (first deploy, 2026-08-09):
upstream's new process-lifetime MCP writer lease exempts only
{pgvector, qdrant}, so the fork's postgres backend (MemPalace#665 lineage,
behind palace-daemon) was treated as single-writer. The daemon's
embedded MCP server took the lease at startup and every
`mempalace mine` subprocess it spawns for POST /mine refused with
'palace ... is held by PID <daemon> (main.py)' — 45 refused transcript
ingests in hook.log before detection.

postgres delegates all cross-process concurrency to the postgres
server, exactly the documented opt-out condition. One-word fix + test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 10, 2026 05:38

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9203c54-4aa6-456e-9f9d-756eb9f3f5e8

📥 Commits

Reviewing files that changed from the base of the PR and between b033c10 and 6b75db6.

📒 Files selected for processing (2)
  • mempalace/palace.py
  • tests/test_palace.py

📝 Walkthrough

Walkthrough

The change classifies PostgreSQL as a multi-process writer backend. Tests verify that PostgreSQL does not require single-writer ownership.

Changes

PostgreSQL writer coordination

Layer / File(s) Summary
Backend classification and validation
mempalace/palace.py, tests/test_palace.py
The backend list includes postgres. The test verifies that backend_requires_single_writer("postgres") returns False.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: igorls, bensig

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the PostgreSQL backend concurrency fix, which is the main change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/postgres-multiprocess-writer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jphein
jphein merged commit 7b4f8d4 into main Aug 10, 2026
14 checks passed
@jphein
jphein deleted the fix/postgres-multiprocess-writer branch August 10, 2026 05:43
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