fix: cancel in-flight backplane I/O on Shutdown#111
Merged
Conversation
Every backplane call (Subscribe/Append/CAS/LoadSnapshot/Compact and the keystore Key/KeyFor) rode context.Background(), so a wedged backend could keep an in-flight call alive forever and block App.Shutdown's drain. Add an app-scoped backplaneCtx/backplaneCancel created in New and cancelled in Shutdown (after the action drain and OnDispose, before backplane.Close so graceful writes still complete). Thread it through all backplane call sites. Closes the panel's #1 production blocker.
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.
Problem (critic panel blocker #1)
Every backplane call site passed
context.Background()—Subscribe,Append,CAS,LoadSnapshot,Compact, and the keystoreKey/KeyFor. A wedged backend could keep an in-flight call alive forever, soApp.Shutdowncould never drain.Fix
backplaneCtx/backplaneCancel, created inNew, cancelled inShutdown.srv.Shutdown) andOnDispose(so graceful writes still complete on a live ctx), beforebackplane.Close().backplaneCtxthrough every backplane I/O call site (incl.StateApp.Update's RMW CAS path).Tests
TestShutdownCancelsInflightBackplaneContext— projector'sSubscribe+LoadSnapshotcontexts are live while running,context.CanceledafterShutdown.TestShutdownCancelsBackplaneWritePathContext— drivesStateApp.Updateand asserts theCAScontext is cancelled byShutdown.Full
ci-check.shgreen (gofmt, vet, golangci, govulncheck, -race, alloc gates).