Add data directory locking and partial corrupt initdb cleanup#892
Open
reisepass wants to merge 2 commits intoelectric-sql:mainfrom
Open
Add data directory locking and partial corrupt initdb cleanup#892reisepass wants to merge 2 commits intoelectric-sql:mainfrom
reisepass wants to merge 2 commits intoelectric-sql:mainfrom
Conversation
Tests that FAIL without the fix — reproducing real corruption: - Overlapping instances: triple, staggered, DDL writer, rapid cycling - HMR double-instance: lock-based blocking and rapid swap corruption - WAL bloat burst mode: rapid kills without checkpoint cause corruption Co-Authored-By: Matthaus Wolff <8714327+WolffM@users.noreply.github.com>
- Add PID-based file lock to NodeFS to prevent overlapping instance corruption - Detect partially-initialized data dirs and move to .corrupt-<timestamp> backup - Add tests verifying partial init backup behavior
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.
I'v been running into issues with pglite getting corrupted in persist to disk mode. The most human scenario is that you have on pnpm dev running in one window and then you start for a quick test not remembering that you already had one open. In my dev work this honestly happens daily so it was hard to use pglite practically as an sqlite replacement.
But simple fix just add a lock file.
This is nothing fancy since postgres assumes it has full control we just reject the second process trying to use the data dir.
And then another small fix for corruption that happens if the file was corrupted due to partial initialization, this is less common but might as-well add another little feature to make it more robust. If a file is there that is so corrupt you can't even find the PG_VERSION it just moves it to a backup and makes another.
^I would be fine also editing this out if someone doesn't like this behavior the Lock file is the important feature