Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible deadlock between sync/consensus service and networking service #1506

Open
tomaka opened this issue Dec 22, 2023 · 1 comment
Open

Comments

@tomaka
Copy link
Contributor

tomaka commented Dec 22, 2023

cc #1483 (comment)

This is a design issue that I introduced during the latest refactoring, and didn't realize it.

If the sync/consensus service subscribes the networking events then freezes for a while, the networking service will at some point stop polling the networking state machine.
Unfortunately, stopping the poll the networking state machine means that we also don't detect request responses.

If the sync/consensus service is frozen because it awaits a networking request, then nothing will ever wake up and there's a deadlock.

Marking a low priority because the sync/consensus service are never supposed to await networking requests. Preventing this deadlock is important because it can be hard to reason about these kind of things when writing new code, but in practice said deadlock can't happen right now.

@tomaka
Copy link
Contributor Author

tomaka commented Jan 3, 2024

One solution could be the combination of:

  • Poll the networking state machine as long as there is any request in progress.
  • Consequently, allow queuing multiple subscription events.
  • Stop accepting new requests from the API user if sending a subscription event is in progress. This requires creating a separate frontend -> background channel dedicated to requests.

Thanks to this, the queue of subscription events to send is still bounded, but there's no deadlock possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant