couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject [09/11] couch-replicator commit: updated refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork to 80708a9
Date Fri, 05 Jun 2015 16:43:05 GMT
continue jobs that aren't _replicator docs

This is a cherry-pick of:

https://github.com/cloudant/couch_replicator/commit/ff1ab1b840019601c3e3e04a1d931db6f2ccd2d1


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

Branch: refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork
Commit: 9d010db16eb172a066c3fa5dc08b904516581dd7
Parents: 86d7716
Author: Robert Newson <rnewson@apache.org>
Authored: Thu May 21 14:08:42 2015 +0100
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Fri Jun 5 17:20:26 2015 +0100

----------------------------------------------------------------------
 src/couch_replicator.erl         |  8 ++++----
 src/couch_replicator_manager.erl | 12 +++++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/9d010db1/src/couch_replicator.erl
----------------------------------------------------------------------
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 @@ 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]),
@@ -486,7 +486,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;

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/9d010db1/src/couch_replicator_manager.erl
----------------------------------------------------------------------
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 @@ 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", "db", _, _, S) ->
@@ -178,7 +180,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;


Mime
View raw message