[ 
https://issues.apache.org/jira/browse/COUCHDB-2833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14941171#comment-14941171
 ] 

ASF GitHub Bot commented on COUCHDB-2833:
-----------------------------------------

GitHub user nickva opened a pull request:

    https://github.com/apache/couchdb-couch-replicator/pull/19

    Handle un-expected closing of pipelined connections better.

    If during a pipelined connection, server closes its socket,
    but http client has more requests to send, ibrowse will
    detect that when it sends next request and throw
    {error, connection_closing}.
    
    Handle that error better, by closing the socket explicitly
    and retrying the pipelined request that failed.
    
    COUCHDB-2833

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nickva/couchdb-couch-replicator 
2833-handle-unexpected-connection-close

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch-replicator/pull/19.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #19
    
----
commit 85d62d1e2b72250c329b4b10db4df1231e647933
Author: Nick Vatamaniuc <[email protected]>
Date:   2015-10-02T13:55:42Z

    Handle un-expected closing of pipelined connections better.
    
    If during a pipelined connection, server closes its socket,
    but http client has more requests to send, ibrowse will
    detect that when it sends next request and throw
    {error, connection_closing}.
    
    Handle that error better, by closing the socket explicitly
    and retrying the pipelined request that failed.
    
    COUCHDB-2833

----


> Replicator client doesn't handle un-expectedly closed pipelined connections 
> well
> --------------------------------------------------------------------------------
>
>                 Key: COUCHDB-2833
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2833
>             Project: CouchDB
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: Database Core
>            Reporter: Nick Vatamaniuc
>
> This was found investigating the failure of replication tests. Specifically 
> couch_replicator_large_atts_tests, the {local, remote} sub-case.
> The test sets up push replications from local to remote.
> Replication workers  have more than 1 document larger than 
> MAX_BULK_ATT_SIZE=64K.  They start pushing them to the target, using a 
> keep-alive connection (default  for HTTP 1.1), the first few pipelined 
> requests will go through using the same connection, then server will accept 
> the first PUT to …/docid?edits=false, then return Connection:close and close 
> the connection after the 201 Created result.  Workers don't expect that, and 
> try to do another PUT on same connection. And then crash on ibrowser's 
> connection_closing error, which they don't handle. That causes the whole 
> async replication process to exit.
> Potentially there are 2 issues.
> couch_replicator_http layer needs to handle this case better. On closing 
> error, shut down the socket quickly and then retry. (Not shutting it down and 
> retrying means retrying for at least 5 or so seconds until something cleans 
> up that connection state).
> Adding this clause to couch_replicator_httpc.erl seems to do the trick:
> {code}
> process_response({error,connection_closing}, Worker, HttpDb, Params, _Cb)->
>     couch_log:notice("Connection closed by server. Closing the socket and 
> trying again",[]),
>     ibrowse_http_client:stop(Worker),
>     throw({retry, HttpDb, Params});
> {code}
> Another issue is to make the server not close the connection after first PUT 
> to .../db/docid?new_edits=false when using pipeline connections.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to