Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
continue jobs that aren't _replicator docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rnewson committed May 21, 2015
1 parent ccafd35 commit ff1ab1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/couch_replicator.erl
Expand Up @@ -453,9 +453,9 @@ handle_cast({db_compacted, DbName},
{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]),
Expand All @@ -464,7 +464,7 @@ handle_cast(checkpoint, State) ->
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;
Expand Down
12 changes: 7 additions & 5 deletions src/couch_replicator_manager.erl
Expand Up @@ -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]).

% gen_server callbacks
-export([start_link/0, init/1, handle_call/3, handle_info/2, handle_cast/2]).
Expand Down Expand Up @@ -130,9 +130,11 @@ replication_error(#rep{id = {BaseId, _} = RepId}, Error) ->
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", "max_replication_retry_count", V, _, S) ->
Expand Down Expand Up @@ -163,7 +165,7 @@ init(_) ->
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;
Expand Down

0 comments on commit ff1ab1b

Please sign in to comment.