Make the testVM pause gate resumable - #488
Draft
samliok wants to merge 3 commits into
Draft
Conversation
pause/resume flipped an atomic that BuildBlock and WaitForPendingBlock read once on entry before blocking on ctx.Done() alone, so resume could not release a caller already parked in the gate. pause now creates a channel that resume closes, and both methods select on it alongside ctx.Done().
Collaborator
Author
|
@yacovm i asked claude to take a look at a flake for one of the instance tests it came up with some nonsense solution with this pr. could you take a look at a better solution when you get the chance? i'm debugging other flakes atm 😅 |
…its a block createFinalizedBlockVerificationTask indexed only the block it verified, so a finalization stored while its sequence was ahead of the storage was never revisited once replication caught up. The node then held a finalized block it could not commit, and any peer that answered with that sequence drove processFinalizedBlock into storeFinalization on a round that already had a finalization, whose error reaches HandleMessage. Index from the round instead, matching persistFinalization.
…ion commits a block" This reverts commit c438f62.
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 was wrong
testVM.pause/resumeonly flipped anatomic.Bool(instance_test.go:686-687).BuildBlockandWaitForPendingBlockread that flag once on entry and then blocked onctx.Done()and nothing else, soresume()could not release a caller already parked in the gate.Consequence
Flakes
TestInstanceRestartAcrossEpochs. The node is restarted while the VM is paused, then resumed. If the restarted node reachesWaitForPendingBlockbeforeresume()runs, it parks indefinitely: the context iscontext.WithCancel(e.finishCtx)frommonitorProgress(simplex/epoch.go:2752) and is only cancelled on a round transition, which cannot happen while that round is waiting for a block to build. The 20srequire.EventuallyinwaitForNumBlocksthen fails with "Condition never satisfied". This also violated theVM.WaitForPendingBlockcontract in config.go:53-55, which says it returns when the VM signals a block should be built.Fix
pause()creates a channel andresume()closes it; both gated methods select on that channel alongsidectx.Done(). While paused no block is produced and context cancellation is still honoured, so the existing "let the caller impatient build time out" behaviour is unchanged. Test-only, no production code touched.Verification
New
TestTestVMResumeWakesPausedCallersfails before the fix ("WaitForPendingBlock did not return after resume"), passes after.Causal link to the flake: inserting a 300ms sleep before the
vm.resume()call madeTestInstanceRestartAcrossEpochsfail deterministically in ~21s with the identical assertion, and that same sleep passes with the fix applied. Both tests pass 3x under-racewith the sleep removed.Found while debugging CI failure https://github.com/ava-labs/Simplex/actions/runs/30949229624/job/92126838329 (
--- FAIL: TestInstanceRestartAcrossEpochs (21.10s)).