Gracefully handle restarts in replica reader - #221
Open
mkuratczyk wants to merge 1 commit into
Open
Conversation
When nodes are restarted in an orderly fashion in a cluster: 1. Prevent badmatch crashes if the socket fails during setopts configuration 2. Check for pending supervisor exit signals in the file transfer loop of `osiris_replica_reader` to avoid blocking supervisor shutdown.
kjnilsson
reviewed
May 29, 2026
|
|
||
| do_sendfile0(State0, 0) -> | ||
| receive | ||
| {'EXIT', _Pid, _Reason} = ExitMsg -> |
Contributor
There was a problem hiding this comment.
I am wondering if this should be a more general "come up to breathe" kind of bit where we exit the send_file loop and resume it if there are no other messages to process.
There was a problem hiding this comment.
Pull request overview
This PR improves osiris_replica_reader robustness during orderly cluster restarts by avoiding crashes on socket option configuration failures and by making the sendfile loop responsive to supervisor shutdown signals.
Changes:
- Guard
setopts/3when enabling{nopush, true}to avoidbadmatchcrashes if the socket is already failing. - Add a periodic mailbox poll in the sendfile loop to notice pending
{'EXIT', ...}messages and stop blocking shutdown. - Stop hard-matching
ok = setopts(...)when disabling{nopush, false}at end-of-stream to avoid termination on socket errors.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+345
to
+348
| receive | ||
| {'EXIT', _Pid, _Reason} = ExitMsg -> | ||
| self() ! ExitMsg, | ||
| State0 |
Comment on lines
+341
to
+351
| do_sendfile0(State) -> | ||
| do_sendfile0(State, 100). | ||
|
|
||
| do_sendfile0(State0, 0) -> | ||
| receive | ||
| {'EXIT', _Pid, _Reason} = ExitMsg -> | ||
| self() ! ExitMsg, | ||
| State0 | ||
| after 0 -> | ||
| do_sendfile0(State0, 100) | ||
| end; |
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.
When nodes are restarted in an orderly fashion in a cluster:
osiris_replica_readerto avoid blocking supervisor shutdown.