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

Dont wait on a disconnected follower #874

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lavinmq/clustering/follower.cr
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module LavinMQ
def close(timeout : Time::Span = 30.seconds)
@closed = true
@actions.close
return if @socket.closed?
if lag_in_bytes > 0
Log.info { "Waiting for follower to be in sync" }
select
Expand Down
4 changes: 4 additions & 0 deletions src/lavinmq/clustering/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@ module LavinMQ
end
rescue ex : AuthenticationError
Log.warn { "Follower negotiation error" }
socket.close
rescue ex : InvalidStartHeaderError
Log.warn { ex.message }
socket.close
rescue ex : IO::EOFError
Log.info { "Follower disconnected" }
socket.close
rescue ex : IO::Error
Log.warn { "Follower disonnected: #{ex.message}" }
socket.close
ensure
follower.try &.close
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't Follower#close close the socket?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will be done by the action loop once it's drained. But we should probably close the socket there is no lag or if we get a timeout waiting for the follower to sync. I guess we could add an ensure statement and always close the socket in #close.

end
Expand Down
Loading