Repository navigation
Release the embedded-database lock when the database closes - #65
Merged
Merged
Conversation
The lock was held until the process exited, so a process that opened and closed the database and then started a server on the same folder (as the HTTP verification scripts do) made the server refuse to start. Several openers in one process now share a claim that is released on close. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lu73uozkZGX8gP8LWNbBqt
5 tasks done
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.
What changed and why
Fixes a regression from #64. That change added a
<folder>.lockfile so two processes cannot open the same PGlite folder, but held it until the process exited. A process that opened and closed the database and then started a server on the same folder, which is whatscripts/verify-identity-http.mjsdoes, made the server refuse to start. The script failed with/api/agents: 503 !== 401.createDatabaseOrmclaims it andorm.close()releases it. Several openers in one process share one claim, and the lock file is removed with the last release.npm run db:migrate) claims the folder inmikro-orm.config.tsfor the life of the command.createMikroOrmOptionsno longer takes the lock itself.How it was verified
pglite-guard.db.test.ts): a process opens and closes the database, stays running, and a second process must be able to open the folder. It fails on the old code with the "already open in another process" refusal and passes with the fix. A second test covers claim counting and lock-file removal.node --import tsx scripts/verify-identity-http.mjspasses (it failed before).db:migrate,db:schema:check,npm run buildand all 15test:httpscripts pass.Not clean: in one full
npm run check,auto-discovery.db.test.ts"stops at its sweep and lifetime limits" timed out (137s against its own 120s limit). Run alone it passes in about 105s on this branch and about 110s on the previous code, so it is slow rather than affected by this change, but it has little headroom. I did not change its timeout. The PostgreSQL variants of the database tests only run in CI. Not exercised on macOS or Windows; the informationalplatformsjob from #64 will show that.Checklist
npm run checkpasses (or the part you could run is listed above) — the full command stopped at the timeout above; every step after it was run separately and passeddocs/contributing/documentation.md(or say why none apply) — the behavior documented in Claude/UI workflow redesign #64 is unchanged apart from when the lock is releaseddocs/security/threat-model.md(not applicable: no change to access control)CHANGELOG.md(not applicable: this corrects an unreleased change)Generated by Claude Code