divijvaidya commented on a change in pull request #1081: TINKERPOP-2169/2173 Responses exceeding maxContentLength cause subsequent queries to hang URL: https://github.com/apache/tinkerpop/pull/1081#discussion_r264821759
########## File path: gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java ########## @@ -291,6 +273,23 @@ public void returnToPool() { } } + /* + * In the event of an IOException (typically means that the Connection might have been closed from the server side + * - this is typical in situations like when a request is sent that exceeds maxContentLength and the server closes + * the channel on its side) or other exceptions that indicate a non-recoverable state for the Connection object + * (a netty CorruptedFrameException is a good example of that), the Connection cannot simply be returned to the + * pool as future uses will end with refusal from the server and make it appear as a dead host as the write will + * not succeed. Instead, the Connection needs to be replaced in these scenarios which destroys the dead channel + * on the client and allows a new one to be reconstructed. + */ + private void handleConnectionCleanupOnError(final Connection thisConnection, final Throwable t) { + if (thisConnection.isDead()) { Review comment: Yes, instead of relying on specific exceptions to determine when to replace a channel vs. returning it to the pool, we explicitly check the channel itself for health status. If the channel is active, it will be returned to the pool, otherwise, it will be replaced. Netty closes the channel on IOExceptions and certain other non-recoverable exceptions. The connection will be replaced as per the new logic which is the same behavior as earlier. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services