Jira (PUP-10347) Client does not reconnect when the server closes a persistent connection

10 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Mar 3, 2020, 8:26:03 PM3/3/20
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-10347
Client does not reconnect when the server closes a persistent connection
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/03/03 5:25 PM
Priority: Normal Normal
Reporter: Josh Cooper

Puppet may fail to reuse a previously cached connection under the following conditions:

1. It uses the new HTTP client
2. The previous request was kept alive (the server didn't send Connection: close)
3. The server closes the connection between the time that the client caches it and when the client tries to reuse it.

Puppet will report that the connection was "interrupted after 0.001 seconds".

The issue occurs because puppet's HTTP client makes a non-local return from the block passed to Net::HTTP#request. As a result the Net::HTTP#end_transport method is never called, which is what sets last_communication to the current timestamp. https://github.com/ruby/ruby/blob/v2_5_7/lib/net/http.rb#L1567

The next time Net::HTTP#request is called, the client's side of the socket is still open and it interprets the nil last_communication value to mean "we've never used this connection before", so it skips the call to Net::HTTP#connect. https://github.com/ruby/ruby/blob/v2_5_7/lib/net/http.rb#L1537-L1546

But as soon as it tries to write the request and read the response, EOFError is raised.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Mar 3, 2020, 8:26:03 PM3/3/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 3, 2020, 8:29:03 PM3/3/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 4, 2020, 9:58:04 AM3/4/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 4, 2020, 1:43:03 PM3/4/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: It was possible for the new HTTP client to try to use a cached HTTP connection, but fail if the server had previously said the connection should be kept alive, but decided to close it later, such as if the server restarted.

Josh Cooper (Jira)

unread,
Mar 4, 2020, 2:44:03 PM3/4/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10347
 
Re: Client does not reconnect when the server closes a persistent connection

Passed CI in e0ec65484cf84f51db5e7d7a4901e624b082c810

Reply all
Reply to author
Forward
0 new messages