Merge remote-tracking branch 'cloudant/2975-restart-replications-on-crash'
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index b838d17..d887d68 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -123,7 +123,7 @@
     ChildSpec = {
         RepChildId,
         {gen_server, start_link, [?MODULE, Rep, [{timeout, Timeout}]]},
-        temporary,
+        transient,
         250,
         worker,
         [?MODULE]
@@ -151,13 +151,6 @@
             %% 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;
@@ -313,16 +306,6 @@
     ]),
     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"
diff --git a/src/couch_replicator_job_sup.erl b/src/couch_replicator_job_sup.erl
index 3cce46c..ef6ffe8 100644
--- a/src/couch_replicator_job_sup.erl
+++ b/src/couch_replicator_job_sup.erl
@@ -22,7 +22,7 @@
 %%=============================================================================
 
 init([]) ->
-    {ok, {{one_for_one, 3, 10}, []}}.
+    {ok, {{one_for_one, 10, 1}, []}}.
 
 %%=============================================================================
 %% internal functions
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 1848153..7c254db 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -578,31 +578,7 @@
     end.
 
 replication_complete(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.
-
+    true = ets:delete(?DOC_TO_REP, {DbName, DocId}).
 
 rep_doc_deleted(DbName, DocId) ->
     case ets:lookup(?DOC_TO_REP, {DbName, DocId}) of
diff --git a/src/couch_replicator_utils.erl b/src/couch_replicator_utils.erl
index c10a4e5..f369408 100644
--- a/src/couch_replicator_utils.erl
+++ b/src/couch_replicator_utils.erl
@@ -367,19 +367,11 @@
         []
     end.
 
-ssl_verify_options(Value) ->
-    ssl_verify_options(Value, erlang:system_info(otp_release)).
-
-ssl_verify_options(true, OTPVersion) when OTPVersion >= "R14" ->
+ssl_verify_options(true) ->
     CAFile = config:get("replicator", "ssl_trusted_certificates_file"),
     [{verify, verify_peer}, {cacertfile, CAFile}];
-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}].
+ssl_verify_options(false) ->
+    [{verify, verify_none}].
 
 
 %% New db record has Options field removed here to enable smoother dbcore migration