Skip to content

Race between Send()/Recv() and Close() in push/pull #185

Description

@tjim

I am using a pull socket with multiple pushers. One pusher sends a message and immediately closes the socket. On the pull side, a Recv() never results in the sent message.

When I observe the network traffic I can see that the pull-side network stack does receive the message before the TCP close.

If I introduce a sufficient delay on the push side before closing, then the message does come back as the result of the Recv(). The delay needs to be greater when the sender is closer, latency-wise, to the receiver. I am currently sleeping 1s, for my current deployment.

Because this is a pull with multiple pushers, the Recv() never returns an error, it continues to return messages sent by other pushers. It's just that the one message is never Recv()'d. So, this case is hard to detect/debug.

I'm not even sure if this is a bug, in any case would appreciate best practices documentation.

I should remark on the comment in issue 111:

So there is a bug here, which is that the send program is simply exiting too quickly, before the message goes out over the wire.

Here I have looked at the network traffic, and have verified that the message does go out over the wire, so that comment does not apply here. However, it may be that #111 is the same issue I am reporting here. I don't know whether the network traffic was examined in #111 as I have done here. My issue is manifesting on the receive side for sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions