You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2020/12/19 15:16:26 UTC

[couchdb] branch replicator-408 created (now 85e2aae)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch replicator-408
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 85e2aae  treat 408 as a retryable error condition

This branch includes the following new commits:

     new 85e2aae  treat 408 as a retryable error condition

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: treat 408 as a retryable error condition

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch replicator-408
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 85e2aae7c8a3ac58607264276a5dd5a3e96c58dc
Author: Robert Newson <rn...@apache.org>
AuthorDate: Sat Dec 19 15:15:22 2020 +0000

    treat 408 as a retryable error condition
---
 .../src/couch_replicator_httpc.erl                 | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator_httpc.erl b/src/couch_replicator/src/couch_replicator_httpc.erl
index cffeb86..52baa39 100644
--- a/src/couch_replicator/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator/src/couch_replicator_httpc.erl
@@ -155,9 +155,15 @@ process_response({ibrowse_req_id, ReqId}, Worker, HttpDb, Params, Callback) ->
 
 process_response({ok, Code, Headers, Body}, Worker, HttpDb, Params, Callback) ->
     case list_to_integer(Code) of
+    R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
+        backoff_success(HttpDb, Params),
+        do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
     429 ->
         backoff(HttpDb, Params);
-    Ok when (Ok >= 200 andalso Ok < 300) ; (Ok >= 400 andalso Ok < 500) ->
+    Error when Error =:= 408 ; Error >= 500 ->
+        couch_stats:increment_counter([couch_replicator, responses, failure]),
+        maybe_retry({code, Error}, Worker, HttpDb, Params);
+    Ok when Ok >= 200 , Ok < 500 ->
         backoff_success(HttpDb, Params),
         couch_stats:increment_counter([couch_replicator, responses, success]),
         EJson = case Body of
@@ -168,13 +174,7 @@ process_response({ok, Code, Headers, Body}, Worker, HttpDb, Params, Callback) ->
         end,
         process_auth_response(HttpDb, Ok, Headers, Params),
         if Ok =:= 413 -> put(?STOP_HTTP_WORKER, stop); true -> ok end,
-        Callback(Ok, Headers, EJson);
-    R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
-        backoff_success(HttpDb, Params),
-        do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
-    Error ->
-        couch_stats:increment_counter([couch_replicator, responses, failure]),
-        maybe_retry({code, Error}, Worker, HttpDb, Params)
+        Callback(Ok, Headers, EJson)
     end;
 
 process_response(Error, Worker, HttpDb, Params, _Callback) ->
@@ -185,10 +185,18 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
     receive
     {ibrowse_async_headers, ReqId, Code, Headers} ->
         case list_to_integer(Code) of
+        R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
+            backoff_success(HttpDb, Params),
+            do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
         429 ->
             Timeout = couch_replicator_rate_limiter:max_interval(),
             backoff(HttpDb#httpdb{timeout = Timeout}, Params);
-        Ok when (Ok >= 200 andalso Ok < 300) ; (Ok >= 400 andalso Ok < 500) ->
+        Error when Error =:= 408 ; Error >= 500 ->
+            couch_stats:increment_counter(
+                [couch_replicator, stream_responses, failure]
+            ),
+            report_error(Worker, HttpDb, Params, {code, Error});
+        Ok when Ok >= 200 , Ok < 500 ->
             backoff_success(HttpDb, Params),
             HttpDb1 = process_auth_response(HttpDb, Ok, Headers, Params),
             StreamDataFun = fun() ->
@@ -206,15 +214,7 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
                         Worker, HttpDb1, Params);
                 throw:{maybe_retry_req, Err} ->
                     maybe_retry(Err, Worker, HttpDb1, Params)
-            end;
-        R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
-            backoff_success(HttpDb, Params),
-            do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
-        Error ->
-            couch_stats:increment_counter(
-                [couch_replicator, stream_responses, failure]
-            ),
-            report_error(Worker, HttpDb, Params, {code, Error})
+            end
         end;
     {ibrowse_async_response, ReqId, {error, _} = Error} ->
         couch_stats:increment_counter(