Skip to content

Gracefully handle restarts in replica reader - #221

Open
mkuratczyk wants to merge 1 commit into
mainfrom
fix-restart-errors
Open

Gracefully handle restarts in replica reader#221
mkuratczyk wants to merge 1 commit into
mainfrom
fix-restart-errors

Conversation

@mkuratczyk

Copy link
Copy Markdown
Contributor

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.

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.

do_sendfile0(State0, 0) ->
receive
{'EXIT', _Pid, _Reason} = ExitMsg ->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/3 when enabling {nopush, true} to avoid badmatch crashes 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants