Skip to content

Commit

Permalink
When monitoring idle connections, only call eof on tcp socket (#912)
Browse files Browse the repository at this point in the history
* When monitoring idle connections, only call eof on tcp socket

In a heavy cloud storage workflow, I encountered the following error:

```
AssertionError: ctx.bytesavailable > 0 || !(ctx.isreadable)
```
with traces back to calling `eof(::SSLContext)` from `monitor_idle_connection`.

As the workflow was highly concurrent, I believe the error was just a data race
between an old async `monitor_idle_connection` task calling `eof` -> `wait_for_decrypted_data`,
but when returning from `wait_for_decrypted_data` due to a new connection being reused in HTTP.jl,
the `handshake` was redone, which resulted in the `AssertionError` shown above.

The proposal here is that when monitoring idle connections, we only call `eof` on the underlying
TCPSocket, since we're really only concerned with knowing whether the core socket gets additional
data, encrypted or not, when we don't expect it.

* simplify
  • Loading branch information
quinnj committed Aug 25, 2022
1 parent 786b1ee commit 976fab5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ConnectionPool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ TODO: or if response data arrives when no request was sent (isreadable == false)
"""
function monitor_idle_connection(c::Connection)
try
if eof(c.io) ;@debugv 3 "💀 Closed: $c"
close(c.io)
if eof(tcpsocket(c.io)) ;@debugv 3 "💀 Closed: $c"
isopen(c.io) && close(c.io)
end
catch ex
@try Base.IOError close(c.io)
Expand Down

0 comments on commit 976fab5

Please sign in to comment.