Repository navigation
fix(acquire): keep the lease's role for the same database - #51
Merged
Merged
Conversation
acquire derived the role name on every call. After #44 changed role naming for long worktree names, an existing long-named dev database mapped to a new role: ensureDatabase handed the database to it while its tables stayed owned by the old role (permission denied), and the rewritten lease lost the old one. acquire now reuses the role stored in an existing lease when that lease is for the same database (fresh drops by it too); new databases keep the new naming. CHANGELOG corrected to describe the real behaviour. Refs: cedar-pg-n8i Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Beads:
cedar-pg-n8iProblem
acquirederived the role name on every call (src/core/lifecycle.ts). After #44 changed role naming for long worktree names, any existing dev database whose name exceeds 58 characters now maps to a new role.ensureDatabasethen hands the database to that role, while the tables inside stay owned by the old one, so the app getspermission deniedon its own dev data. The rewritten lease also drops the old role, which is left orphaned. The CHANGELOG claim "existing leases keep their stored role" only held until the next acquire.Fix
acquirereuses the role stored in an existing lease when that lease is for the same database. It keeps writing that role into the lease, andfreshdrops by it.I picked lease reuse over
REASSIGN OWNED, as the bead asked. It's a two-line change in the canonical layer and needs no per-database connection.Tests
tests/lifecycle-acquire.test.ts(mocked host and provider) covers three cases:acquirekeeps that role forensureDatabase,freshand the lease;autopg postmasteron a temp port and data dir (never the shared host), with a stubAUTOPG_BINreporting that port, drove the builtacquire.42501 permission denied for table t. That is the pre-fix failure.smoke:pgdoes not cover this upgrade path.Checks
vp check: passvp test: 22 files, 138 tests passvp run smoke:pg: pass🤖 Generated with Claude Code