continue jobs that aren't _replicator docs
This is a cherry-pick of:
https://github.com/cloudant/couch_replicator/commit/ff1ab1b840019601c3e3e04a1d931db6f2ccd2d1
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index 3a744cd..f8a3e65 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -475,9 +475,9 @@
{noreply, State#rep_state{target = NewTarget}};
handle_cast(checkpoint, State) ->
- #rep_state{rep_details = #rep{id = RepId} = Rep} = State,
- case couch_replicator_manager:owner(RepId) of
- Owner when Owner == node() ->
+ #rep_state{rep_details = #rep{} = Rep} = State,
+ case couch_replicator_manager:continue(Rep) of
+ {true, _} ->
case do_checkpoint(State) of
{ok, NewState} ->
couch_stats:increment_counter([couch_replicator, checkpoints, success]),
@@ -486,7 +486,7 @@
couch_stats:increment_counter([couch_replicator, checkpoints, failure]),
{stop, Error, State}
end;
- Owner ->
+ {false, Owner} ->
couch_replicator_manager:replication_usurped(Rep, Owner),
{stop, shutdown, State}
end;
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 7bb5078..b74ba41 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -17,7 +17,7 @@
% public API
-export([replication_started/1, replication_completed/2, replication_error/2]).
--export([owner/1, replication_usurped/2]).
+-export([continue/1, replication_usurped/2]).
-export([before_doc_update/2, after_doc_read/2]).
@@ -131,9 +131,11 @@
ok = gen_server:call(?MODULE, {rep_error, RepId, Error}, infinity)
end.
-
-owner(RepId) ->
- gen_server:call(?MODULE, {owner, RepId}).
+continue(#rep{doc_id = null}) ->
+ {true, no_owner};
+continue(#rep{id = RepId}) ->
+ Owner = gen_server:call(?MODULE, {owner, RepId}),
+ {node() == Owner, Owner}.
handle_config_change("replicator", "db", _, _, S) ->
@@ -178,7 +180,7 @@
handle_call({owner, RepId}, _From, State) ->
case rep_state(RepId) of
nil ->
- false;
+ {reply, nonode, State};
#rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
{reply, owner(DbName, DocId, State#state.live), State}
end;