Skip to content

Handle ENOTCONN#102

Merged
gmmeyer merged 3 commits intoDataDog:masterfrom
blaines:patch-1
Jan 18, 2019
Merged

Handle ENOTCONN#102
gmmeyer merged 3 commits intoDataDog:masterfrom
blaines:patch-1

Conversation

@blaines
Copy link
Copy Markdown
Contributor

@blaines blaines commented Jan 16, 2019

Unset socket under the condition ENOTCONN this could happen in the event the datadog agent is restarted and using a unix socket file.

  • Unset socket in the condition a connection is lost
  • Added test to handle ENOTCONN

Unset socket under the condition ENOTCONN this could happen in the event the datadog agent is restarted and using a unix socket file.
Comment thread lib/datadog/statsd.rb
bad_socket = !@socket_path.nil? && (
boom.is_a?(Errno::ECONNREFUSED) ||
boom.is_a?(Errno::ECONNRESET) ||
boom.is_a?(Errno::ENOTCONN) ||
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might actually be better to not add this and instead relax the retry conditions on this line

if retries <= 1 && boom.is_a?(IOError) && boom.message =~ /closed stream/i

to just

        if retries <= 1

In our case as well as I'm sure in many others, we'd much rather immediately retry establishing the socket and resending the message rather than losing the message and having to wait for the next one for the socket to re-establish itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I changed the logic to retry the same message upon ENOTCONN

Copy link
Copy Markdown
Contributor

@gmmeyer gmmeyer left a comment

Choose a reason for hiding this comment

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

this looks good to me! thanks a lot for doing this! 😄

@gmmeyer gmmeyer merged commit e1c5908 into DataDog:master Jan 18, 2019
@Shadow6363
Copy link
Copy Markdown

Hey @gmmeyer, thanks for merging this! Is there a standard release schedule you follow? Just wondering when I should update our agents to pull this in.

@Shadow6363
Copy link
Copy Markdown

Also, just realized @blaines, you never removed the original version of your code. There's a return block after that if so your change to retry isn't actually ever going to get reached. :/

blaines added a commit to blaines/dogstatsd-ruby that referenced this pull request Jan 23, 2019
blaines added a commit to blaines/dogstatsd-ruby that referenced this pull request Jan 23, 2019
@masci masci added this to the 4.1.0 milestone Mar 8, 2019
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.

4 participants