Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[dogstatsd] Handle EAGAIN socket error when dropping packets #515
Conversation
| @@ -399,8 +399,11 @@ def _send_to_server(self, packet): | |||
| # dogstatsd is overflowing, drop the packets (mimicks the UDP behaviour) | |||
| pass | |||
| except (socket.error, socket.herror, socket.gaierror) as se: | |||
| log.warning("Error submitting packet: {}, dropping the packet and closing the socket".format(se)) | |||
| self.close_socket() | |||
| if se.errno == 11: | |||
This comment has been minimized.
This comment has been minimized.
jd
Jan 15, 2020
Member
This should be errno.EAGAIN.
The number is different depending on the platform.
I'd also prefer to see that under a specific socket.error except statement to be clearer. Catching everything like this is done is not a good thing, we should make clear things a bit.
This comment has been minimized.
This comment has been minimized.
mrknmc
Jan 15, 2020
Author
Contributor
Good point on errno.EAGAIN.
What do you mean by a specific socket.error except statement? I can create a separate statement but if we want to keep the logic the same for non-EAGAIN errors, I'd have to add the close_socket logic there as well.
This comment has been minimized.
This comment has been minimized.
jd
Jan 15, 2020
Member
I mean:
except socket.error:
if not EAGAIN:
close()
except (socket.herror, socket.gaierror):
close()in summary :)
|
|
||
| def send(self, payload): | ||
| error = socker.error("Socker error") | ||
| error.errno = 11 |
This comment has been minimized.
This comment has been minimized.
…ndling
|
Thanks for the fix! |
|
/azp run DataDog.datadogpy.integration |
azure-pipelines
bot
commented
Jan 15, 2020
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
We might want to handle |
@mrknmc Many thanks for following up on our comments! |
No problem, thanks for looking over it! :) |
|
@mrknmc Sorry almost ready to go, but the branch is now out of sync with the master branch. Can you update it and we should be good to go. |
Are you ok with a rebase or do you want me to merge |
I would say the latter, merge |
|
/azp run DataDog.datadogpy.integration |
azure-pipelines
bot
commented
Jan 20, 2020
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@dabcoder we should be good to go now, correct? |
|
Yes all good thanks |
mrknmc commentedJan 14, 2020
•
edited by jirikuncar
What does this PR do?
Fixes #514 by catching
socket.errorand checkingerrno == 11(EAGAIN) and logs a warning without closing the socket.Description of the Change
As mentioned in the issue,
socket.sendraises aBlockingIOError (socket.error on py2)exception when the socket is "full" rather than asocket.timeoutexception. Hence, we create a new branch in the try-raise where we catchsocket.error, check theerrnoand log a warning without closing the socket. This works across both python 2 and 3.I left the
socket.timeoutbranch in place because I wasn't sure if there is another way to set up DogStatsd wheresocket.timeoutis thrown when the socket is full. This way, the change shouldn't break compatibility for people who rely on that behaviour.Alternate Designs
I considered not logging a message when a
socket.errorwitherrno == 11occurs but thought that people might want to be informed about this happening.Possible Drawbacks
N/A
Verification Process
I created a unit test and checked that it passes.
Additional Notes
N/A
Release Notes
N/A
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.