Fix push/pull mutex lifecycle in LeaderSyncProcessor#1029
Open
slashv wants to merge 2 commits intolivestorejs:devfrom
Open
Fix push/pull mutex lifecycle in LeaderSyncProcessor#1029slashv wants to merge 2 commits intolivestorejs:devfrom
slashv wants to merge 2 commits intolivestorejs:devfrom
Conversation
…utex-leak # Conflicts: # packages/@livestore/common/src/leader-thread/LeaderSyncProcessor.ts
Contributor
|
Thanks for tackling this - the mutex lifecycle changes look solid and the paginated non-live regression test is very helpful. One coverage gap I still see: could we add tests for lock release on non-happy paths during paginated pull?
Those seem like the most subtle regressions for this area and would give stronger confidence that + always prevent stalls. Also, could you please rebase this branch onto latest and fix the current lint issue before merge? Thanks again for driving this fix. |
Contributor
|
Small follow-up/correction (my previous comment had formatting glitches from CLI escaping): The two symbols I referenced are releasePullMutexIfHeld and Effect.ensuring. Request remains the same:
Thanks again for the fix and for following up on this. |
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.
Preface
Full disclosure, Codex 5.3 was used to both identify and solve this bug. I was experiencing a sync dead-lock in my LiveStore app when doing heavy bursts of events at startup. After implementing this and running my app against LiveStore with this fix it solved the problem.
I have a conceptual understanding of why this occurred as well as the solution but I have not written any code by hand nor have I examined every line in detail.
Problem
What problem does this pull request address?
pushPullMutexcould remain held on some failure/exit paths.Solution
How does this change resolve the problem? Mention trade-offs and alternatives considered.
withPermits(1)).NoMore)ensuring)Validation
What did you do to verify the change?
direnv exec . vitest run tests/package-common/src/leader-thread/LeaderSyncProcessor.test.tsdirenv exec . mono tsdirenv exec . mono lint --fixDemo (optional)