couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject couch-replicator commit: updated refs/heads/master to fb004ea
Date Fri, 25 Mar 2016 15:48:16 GMT
Repository: couchdb-couch-replicator
Updated Branches:
  refs/heads/master 89d57cd10 -> fb004ea6f


Revert "Merge remote-tracking branch 'cloudant/2975-restart-replications-on-crash'"

This reverts commit 89d57cd10d36eb9a5b300568bad037d99998e241, reversing
changes made to 197950631b8a73a8c36b744fc9eb00debc15ac03.


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/fb004ea6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/fb004ea6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/fb004ea6

Branch: refs/heads/master
Commit: fb004ea6f1c1740fec9deb76e475a73ce5353e63
Parents: 89d57cd
Author: Robert Newson <rnewson@apache.org>
Authored: Fri Mar 25 15:46:40 2016 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Fri Mar 25 15:46:40 2016 +0000

----------------------------------------------------------------------
 src/couch_replicator.erl         | 19 ++++++++++++++++++-
 src/couch_replicator_job_sup.erl |  2 +-
 src/couch_replicator_manager.erl | 26 +++++++++++++++++++++++++-
 src/couch_replicator_utils.erl   | 14 +++++++++++---
 4 files changed, 55 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/fb004ea6/src/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index d887d68..b838d17 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -123,7 +123,7 @@ async_replicate(#rep{id = {BaseId, Ext}, source = Src, target = Tgt} =
Rep) ->
     ChildSpec = {
         RepChildId,
         {gen_server, start_link, [?MODULE, Rep, [{timeout, Timeout}]]},
-        transient,
+        temporary,
         250,
         worker,
         [?MODULE]
@@ -151,6 +151,13 @@ async_replicate(#rep{id = {BaseId, Ext}, source = Src, target = Tgt}
= Rep) ->
             %% the Pid by calling start_child again.
             timer:sleep(50 + random:uniform(100)),
             async_replicate(Rep);
+        {error, {'EXIT', {badarg,
+            [{erlang, apply, [gen_server, start_link, undefined]} | _]}}} ->
+            % Clause to deal with a change in the supervisor module introduced
+            % in R14B02. For more details consult the thread at:
+            %     http://erlang.org/pipermail/erlang-bugs/2011-March/002273.html
+            _ = supervisor:delete_child(couch_replicator_job_sup, RepChildId),
+            async_replicate(Rep);
         {error, _} = Error ->
             Error
         end;
@@ -306,6 +313,16 @@ do_init(#rep{options = Options, id = {BaseId, Ext}, user_ctx=UserCtx}
= Rep) ->
     ]),
     couch_task_status:set_update_frequency(1000),
 
+    % Until OTP R14B03:
+    %
+    % Restarting a temporary supervised child implies that the original arguments
+    % (#rep{} record) specified in the MFA component of the supervisor
+    % child spec will always be used whenever the child is restarted.
+    % This implies the same replication performance tunning parameters will
+    % always be used. The solution is to delete the child spec (see
+    % cancel_replication/1) and then start the replication again, but this is
+    % unfortunately not immune to race conditions.
+
     couch_log:notice("Replication `~p` is using:~n"
         "~c~p worker processes~n"
         "~ca worker batch size of ~p~n"

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/fb004ea6/src/couch_replicator_job_sup.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_job_sup.erl b/src/couch_replicator_job_sup.erl
index ef6ffe8..3cce46c 100644
--- a/src/couch_replicator_job_sup.erl
+++ b/src/couch_replicator_job_sup.erl
@@ -22,7 +22,7 @@ start_link() ->
 %%=============================================================================
 
 init([]) ->
-    {ok, {{one_for_one, 10, 1}, []}}.
+    {ok, {{one_for_one, 3, 10}, []}}.
 
 %%=============================================================================
 %% internal functions

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/fb004ea6/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 7c254db..1848153 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -578,7 +578,31 @@ start_replication(Rep, Wait) ->
     end.
 
 replication_complete(DbName, DocId) ->
-    true = ets:delete(?DOC_TO_REP, {DbName, DocId}).
+    case ets:lookup(?DOC_TO_REP, {DbName, DocId}) of
+    [{{DbName, DocId}, {BaseId, Ext} = RepId}] ->
+        case rep_state(RepId) of
+        nil ->
+            % Prior to OTP R14B02, temporary child specs remain in
+            % in the supervisor after a worker finishes - remove them.
+            % We want to be able to start the same replication but with
+            % eventually different values for parameters that don't
+            % contribute to its ID calculation.
+            case erlang:system_info(otp_release) < "R14B02" of
+            true ->
+                spawn(fun() ->
+                    _ = supervisor:delete_child(couch_replicator_job_sup, BaseId ++ Ext)
+                end);
+            false ->
+                ok
+            end;
+        #rep_state{} ->
+            ok
+        end,
+        true = ets:delete(?DOC_TO_REP, {DbName, DocId});
+    _ ->
+        ok
+    end.
+
 
 rep_doc_deleted(DbName, DocId) ->
     case ets:lookup(?DOC_TO_REP, {DbName, DocId}) of

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/fb004ea6/src/couch_replicator_utils.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_utils.erl b/src/couch_replicator_utils.erl
index f369408..c10a4e5 100644
--- a/src/couch_replicator_utils.erl
+++ b/src/couch_replicator_utils.erl
@@ -367,11 +367,19 @@ ssl_params(Url) ->
         []
     end.
 
-ssl_verify_options(true) ->
+ssl_verify_options(Value) ->
+    ssl_verify_options(Value, erlang:system_info(otp_release)).
+
+ssl_verify_options(true, OTPVersion) when OTPVersion >= "R14" ->
     CAFile = config:get("replicator", "ssl_trusted_certificates_file"),
     [{verify, verify_peer}, {cacertfile, CAFile}];
-ssl_verify_options(false) ->
-    [{verify, verify_none}].
+ssl_verify_options(false, OTPVersion) when OTPVersion >= "R14" ->
+    [{verify, verify_none}];
+ssl_verify_options(true, _OTPVersion) ->
+    CAFile = config:get("replicator", "ssl_trusted_certificates_file"),
+    [{verify, 2}, {cacertfile, CAFile}];
+ssl_verify_options(false, _OTPVersion) ->
+    [{verify, 0}].
 
 
 %% New db record has Options field removed here to enable smoother dbcore migration


Mime
View raw message