Repository navigation
fix(service): stop an unsubscribe from deadlocking the bus - #3
Merged
Merged
Conversation
Unsubscribe took the lock once per subscriber it looked at, each unlock deferred to its return: a websocket closing while it was not the first subscriber of an event locked the bus's mutex twice and never came back. Every subscription after it hung once its websocket was open, so the subscriber believed it was listening and received nothing. The core's alerts, which resubscribe each time the core restarts, hit it on every install check: three connections closed together, the third deadlocked. The lock is now taken once per call, in both services. The dispatch reads the subscriber lists under it too, as a map read while Subscribe writes it can bring the bus down. And two silent drops go: a publish waits for the dispatch instead of dropping an event it is busy with, and a subscriber may be 64 events behind instead of one.
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.
A websocket closing while it was not the first subscriber of an event deadlocked the bus:
Unsubscribelocked the mutex once per subscriber it looked at, each unlock deferred. Every subscription after that hung once its websocket was open, which is why the core's push alerts never receivedbackup:errorin the v0.5.10 install check.EventServiceWSandActionServiceWSTests:
TestUnsubscribeASubscriberAfterTheFirstdeadlocks on the old code;TestEventsPublishedTogetherAllArrive.