Github user nickva commented on a diff in the pull request:

    
https://github.com/apache/couchdb-couch-replicator/pull/37#discussion_r61345382
  
    --- Diff: src/couch_replicator_manager.erl ---
    @@ -124,13 +126,25 @@ replication_error(#rep{id = {BaseId, _} = RepId}, 
Error) ->
         nil ->
             ok;
         #rep_state{rep = #rep{db_name = DbName, doc_id = DocId}} ->
    +        add_error_jitter(),
             update_rep_doc(DbName, DocId, [
                 {<<"_replication_state">>, <<"error">>},
                 {<<"_replication_state_reason">>, 
to_binary(error_reason(Error))},
                 {<<"_replication_id">>, ?l2b(BaseId)}]),
             ok = gen_server:call(?MODULE, {rep_error, RepId, Error}, infinity)
         end.
     
    +% Add random delay proportional to the number of replications
    +% on current node, in order to prevent a stampede when a source
    +% with multiple replication targets fails
    +add_error_jitter() ->
    +    RepCount = ets:info(?REP_TO_STATE, size),
    +    Range = RepCount * 2 * ?AVG_ERROR_DELAY_MSEC,
    --- End diff --
    
    Since config macro is called "average error", then made the random uniform 
range * 2. For example if need an average of 50,  sample from a uniform 
interval of 0 to 100.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to