Repository navigation
Wait for open before suspending and release waiters if suspend fails - #126
Merged
Merged
Conversation
_suspend() sets this.resumed before calling binding.suspend(), but never waits for the database to open. Calling suspend() while the open is still in flight makes binding.suspend() throw "invalid argument" (EINVAL), and because the throw skips both `this._suspended = true` and any cleanup, this.resumed stays pending forever: resume() then sees _suspending === _suspended and returns without calling _resume(), so every later read, write, flush or compact hangs in waitForResume(). This waits for the open first, like every other operation in RocksDBState, and if the native suspend still fails it clears and resolves this.resumed before rethrowing, so a failed suspend leaves the database usable instead of hanging. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
kasperisager
approved these changes
Oct 30, 2026
kasperisager
left a comment
Contributor
There was a problem hiding this comment.
Thanks, great catch! The change looks good, I'll land and release when green.
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.
Calling
suspend()while the database is still opening deadlocks it._suspend()setsthis.resumed = rrp()and then callsbinding.suspend(), which throwsinvalid argument(EINVAL) because the open hasn't finished. The throw skipsthis._suspended = true, sothis.resumedis never resolved:resume()sees_suspending === _suspended, returns without calling_resume(), and every laterget(), write, flush or compact waits forever inwaitForResume(). Smallest repro:The fix makes
_suspend()wait for the open first, like every other operation inRocksDBState, and if the native suspend still fails it clears and resolvesthis.resumedbefore rethrowing, so a failed suspend no longer leaves the database hung.The new test fails without the fix (
Error: invalid argumentfrombinding.suspend) and passes with it. The full suite passes on Node and Bare (85/85).Analysed with help from Claude (AI).
🤖 Generated with Claude Code