Repository navigation
34 35 fix minows rpc lifecycle - #41
Merged
Merged
Conversation
JonKuqi
marked this pull request as ready for review
August 25, 2026 13:47
JonKuqi
force-pushed
the
34-35-fix-minows-rpc-lifecycle
branch
from
August 25, 2026 16:48
da4ba14 to
cab68f8
Compare
PascalinDe
reviewed
Aug 26, 2026
PascalinDe
reviewed
Aug 26, 2026
PascalinDe
reviewed
Aug 26, 2026
PascalinDe
reviewed
Aug 26, 2026
JonKuqi
force-pushed
the
34-35-fix-minows-rpc-lifecycle
branch
from
August 26, 2026 15:23
d2d2cfd to
cb96354
Compare
JonKuqi
force-pushed
the
34-35-fix-minows-rpc-lifecycle
branch
from
August 26, 2026 15:26
cb96354 to
efaf310
Compare
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.
closes #34
closes #35
Problem 1
The problem was revealed after a load test on dvoting creating forms, causing the streams to leak and blocked.
Every unary
Callopened a new libp2p stream inunicast. Neither the client nor server closed that stream after the response completed:openStreaminstead created a goroutine that waited for the caller's context:dela/mino/minows/rpc.go
Lines 252 to 258 in 8881acd
D-Voting reused long-lived contexts. Completed streams and cancellation goroutines therefore accumulated until libp2p rejected new streams.
After the load test on create forms:
Libp2p defines
0x1002asStreamResourceLimitExceeded.The fix gives the stream to the RPC operation that actually owns it:
Cancellation still resets an in-flight unary call so a blocked read is interrupted, but the cancellation callback is removed when the call has already completed.
Cancellation still resets an unfinished unary call to interrupt blocked I/O. The cancellation callback is stopped when the call completes normally.
Problem 2 — Streaming RPC resources were not closed correctly
Streaming RPCs had several related lifecycle problems:
handler.Streamreturned.Reset, which could discard a recently written message before the remote side consumed it.The fix gives each streaming resource an explicit lifetime:
handleStreamnow closes the participant-side stream when its handler returns. Normal orchestrator shutdown uses gracefulClose, whileResetremains limited to aborting unfinished unary calls.If any requested participant cannot be reached,
Streamstill returns an error. Allowing threshold protocols to proceed with reachable participants is handled separately.Verification
The added regressions cover:
context.Canceledfor sends after session termination.go test ./mino/minows -count=1