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

Issue-1103 - Fixing broken pipe errors #1170

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

Kannav02
Copy link
Contributor

The identification of broken pipe is only when there is an abrupt exit, so what I saw in the codebase was there are only a couple of places that deal with the closure of WebSocket connections, most of them were only handling the case where the user exited irrespective if it was gracefully or abruptly, so I modified and added some sections for the same

  • in the closing_handshake , it wasn't checking if the closeValue had an error, indicating that there was an error while closing the connection, so I added a check for the same
  • now when a message is being read, if there is an error that belongs to the errs category, it means that there is a graceful exit, otherwise, the exit was due to another error, so I have added the check for the same
  • In the WriteResponseWithRetries you have a case where the function returns the syscall.EPIPE error, this function is utilized in WebSocketHandler function, so I have added the check for the same

Those were all the that i found were capable of returning broken pipe errors, i have provided the segregated messages for the same, please do let me know if any other changes or features are needed

Fixes #1103

Thank you!

@JyotinderSingh
Copy link
Collaborator

Thanks for this contribution, please fix the lint errors and merge conflicts

@Kannav02
Copy link
Contributor Author

Hey @JyotinderSingh!

Sure, i would resolve the merge conflicts, however I believe the linting errors existed even before I tried to make any change as they are in files different to the one I had made changes to, I don't want to break the codebase

@Kannav02 Kannav02 force-pushed the issue-1103 branch 2 times, most recently from 724ec50 to fecbd7f Compare October 22, 2024 01:03
@Kannav02
Copy link
Contributor Author

Hey @JyotinderSingh!

I think the code should be good for review now , thank you for the help

@Kannav02
Copy link
Contributor Author

Kannav02 commented Oct 22, 2024

There's merge conflicts again, I assume a PR got merged, I'll fix it

@Kannav02 Kannav02 force-pushed the issue-1103 branch 2 times, most recently from 5a70778 to f60e85b Compare October 22, 2024 18:55
@Kannav02
Copy link
Contributor Author

I have rebased the branch again to follow the linear path for the new master branch with merged PRs.

Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

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

Thanks for these changes. Left a couple of comments.

if !websocket.IsCloseError(err, errs...) {
slog.Warn("failed to read message from client", slog.Any("error", err))
if websocket.IsCloseError(err, errs...) {
slog.Info("Gracefully Exited")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't need to be logged.

}

if messageType == websocket.CloseMessage {
slog.Info("graceful shutdown...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not need to be logged.

_ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
if closeErr != nil {
slog.Warn("Error during closing handshake", slog.Any("error", closeErr))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make this a debug log.

    - imports changed
    - outdented the code from the else block due to break statement in
      if block
    - removed extra blank line for consistent formatting
@Kannav02
Copy link
Contributor Author

I have included your suggestions in the codebase, please let me know if you need any other changes as well

Thank you!

Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for this contribution!

@JyotinderSingh JyotinderSingh merged commit 7e04547 into DiceDB:master Oct 26, 2024
2 checks passed
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.

Investigate and fix "broken pipe" errors
2 participants