nickva opened a new pull request, #4736:
URL: https://github.com/apache/couchdb/pull/4736

   Previously, when processing long running streaming requests, such as _find 
with a highly selective selector, when no rows are emitted for a while, the 
client could disconnect but the request process, and all the associated workers 
on remote nodes would continue running, consuming server resources.
   
   We already handle remote (RPC) process cleanup if the coordinator crashes, 
we just need a way to kill that coordinator if the connection is closed in the 
case when no data may be emitted for a long time. This is what the current 
commit accomplishes.
   
   It turns out there is no simple way to detect passive mode socket 
disconnects in current versions of Erlang/OTP. The socket at the kernel level 
may be closed (in close_wait state), however `inet:info/1` will continue 
reporting it as `connected`. The only ways to obtain an accurate connection 
state is to try to write, read, or query the TCP info state.
   
   Here we attempt to query the state with tcp_info. Unfortunately, not all 
versions of supported OTP platforms have this option, so it probably never 
became an officially supported inet socket option, so we use `raw` socket 
option for it. However, it turns out most of CouchDB supported platforms do 
have that option. The only platform this is not working currently is Windows. 
In that case, or future platform cases we default to the previous behavior, 
assuming the socket is still open.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to