question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bytes are dropped when using epoll and auto read = false when peer closes connection

See original GitHub issue

Expected behavior

Received but not yet emitted bytes at time of peer connection close when using epoll edge triggered and autoRead=false should be emitted (i.e. behaviour as of 4.1.6).

Actual behavior

As of 4.1.7, As soon as the remote peer disconnects, no further bytes will be emitted.

The problematic change is here: https://github.com/netty/netty/commit/631077c79391fde22afdb1e43d0f642ba530101e#diff-5d2d71235faad7440ee0020202cfa744L59

This is effectively a different take on #3709, but for the non auto read case and is a regression introduced to fix #6173.

maybeMoreDataToRead() && config.isAutoRead() || super.continueReading() is always false when autoRead=false. This means that queued up bytes are not drained https://github.com/netty/netty/blob/4.1/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java#L378 when EPOLLRDHUP is read, and the subsequent shutdownInput(); causes future channel.read() calls to effectively NOOP because of https://github.com/netty/netty/blob/4.1/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java#L972 (i.e. isInputShutdown() is true).

I don’t know what the right fix is, but my best naive guess would be to change the start of epollInReady() to be:

if (!maybeMoreDataToRead && fd().isInputShutdown()) {
  clearEpollIn0();
  return;
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Scottmitchcommented, Feb 15, 2017

@alkemist - thanks for the repro … looking now.

0reactions
Scottmitchcommented, Feb 16, 2017

@alkemist - Great! Thanks for the reproducer … makes life so much easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

epoll loops on disconnection of a client - Stack Overflow
A client disconnection is signalled by an EOF condition on the file descriptor. The system considers EOF to be a state in which...
Read more >
EpollSocketChannelConfig (Netty API Reference (4.0.56.Final))
Returns true if and only if the channel should not close itself when its remote peer shuts down output to make the connection...
Read more >
reactor/reactor-netty - Gitter
We are getting Netty Connection reset by peer issue in our Spring Cloud Gateway application. We think the remote is load balancer. We...
Read more >
Detection of Half-Open (Dropped) Connections - Stephen Cleary
Half-closed connections are when one side performs a Shutdown operation on its socket, shutting down only the sending (outgoing) stream. See ...
Read more >
Principles to Handle Thousands of Connections in Java Using ...
If we used one TCP connection only for sending one message, we would pay the overhead of 8 TCP segments (connect and close...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found