You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2016/05/30 23:15:06 UTC

[1/2] couch-replicator commit: updated refs/heads/3010-handle-429 to 7f0f3d7

Repository: couchdb-couch-replicator
Updated Branches:
  refs/heads/3010-handle-429 c6e891d26 -> 7f0f3d7e8


Clean up syntax

COUCHDB-3010


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/665b0a7f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/665b0a7f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/665b0a7f

Branch: refs/heads/3010-handle-429
Commit: 665b0a7f94404c1af5d338ad2a8345bc94174db8
Parents: c6e891d
Author: Tony Sun <to...@cloudant.com>
Authored: Mon May 30 16:11:47 2016 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Mon May 30 16:11:47 2016 -0700

----------------------------------------------------------------------
 src/couch_replicator_httpc.erl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/665b0a7f/src/couch_replicator_httpc.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_httpc.erl b/src/couch_replicator_httpc.erl
index 601de06..5013de3 100644
--- a/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator_httpc.erl
@@ -28,6 +28,7 @@
 -define(replace(L, K, V), lists:keystore(K, 1, L, {K, V})).
 -define(MAX_WAIT, 5 * 60 * 1000).
 -define(MAX_BACKOFF_WAIT, 250 * 32768).
+-define(MAX_BACKOFF_LOG_THRESHOLD, 512000).
 -define(STREAM_STATUS, ibrowse_stream_status).
 
 
@@ -139,7 +140,7 @@ 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
-    C when C =:= 429 ->
+    429 ->
         maybe_retry(back_off, Worker, HttpDb, Params);
     Ok when (Ok >= 200 andalso Ok < 300) ; (Ok >= 400 andalso Ok < 500) ->
         couch_stats:increment_counter([couch_replicator, responses, success]),
@@ -165,7 +166,7 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
     receive
     {ibrowse_async_headers, ReqId, Code, Headers} ->
         case list_to_integer(Code) of
-        C when C =:= 429 ->
+        429 ->
             maybe_retry(back_off, Worker,
                 HttpDb#httpdb{timeout = ?MAX_BACKOFF_WAIT}, Params);
         Ok when (Ok >= 200 andalso Ok < 300) ; (Ok >= 400 andalso Ok < 500) ->
@@ -264,7 +265,7 @@ maybe_retry(backoff, Worker, #httpdb{wait = Wait} = HttpDb, Params) ->
     ok = timer:sleep(random:uniform(Wait)),
     Wait2 = Wait*2,
     case Wait2 of
-        W0 when W0 >= 512000 -> % Past 8 min, we log retries
+        W0 when W0 >= ?MAX_BACKOFF_LOG_THRESHOLD -> % Past 8 min, we log retries
             log_retry_error(Params, HttpDb, Wait, "429 Retry");
         W1 when W1 > ?MAX_BACKOFF_WAIT ->
             report_error(Worker, HttpDb, Params, {error,


[2/2] couch-replicator commit: updated refs/heads/3010-handle-429 to 7f0f3d7

Posted by to...@apache.org.
Add random for next wait in maybe_retry

COUCHDB-3010


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/7f0f3d7e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/7f0f3d7e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/7f0f3d7e

Branch: refs/heads/3010-handle-429
Commit: 7f0f3d7e883be81946f1dbc0108649fc81772964
Parents: 665b0a7
Author: Tony Sun <to...@cloudant.com>
Authored: Mon May 30 16:17:09 2016 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Mon May 30 16:17:09 2016 -0700

----------------------------------------------------------------------
 src/couch_replicator_httpc.erl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/7f0f3d7e/src/couch_replicator_httpc.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_httpc.erl b/src/couch_replicator_httpc.erl
index 5013de3..f3fbd58 100644
--- a/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator_httpc.erl
@@ -283,7 +283,8 @@ maybe_retry(Error, _Worker, #httpdb{retries = Retries, wait = Wait} = HttpDb,
     % backwards compatibility.
     ok = timer:sleep(erlang:min(Wait, ?MAX_WAIT)),
     Wait2 = erlang:min(Wait * 2, ?MAX_WAIT),
-    NewHttpDb = HttpDb#httpdb{retries = Retries - 1, wait = Wait2},
+    WaitR = random:uniform(Wait2),
+    NewHttpDb = HttpDb#httpdb{retries = Retries - 1, wait = WaitR},
     throw({retry, NewHttpDb, Params}).