couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [26/27] couch-replicator commit: updated refs/heads/windsor-merge to 75e5ba1
Date Wed, 06 Aug 2014 18:18:16 GMT
Owner must be live

BugzID: 31712


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

Branch: refs/heads/windsor-merge
Commit: 22e9ff4838b29f0a1080a82a4845808caf96fa6c
Parents: f90b6e0
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Jun 16 13:37:58 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jul 31 11:56:46 2014 +0100

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/22e9ff48/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index bcb6462..c145b75 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -380,7 +380,7 @@ rescan(#state{scan_pid = ScanPid} = State) ->
 process_update(State, DbName, {Change}) ->
     {RepProps} = JsonRepDoc = get_json_value(doc, Change),
     DocId = get_json_value(<<"_id">>, RepProps),
-    case {is_owner(DbName, DocId), get_json_value(deleted, Change, false)} of
+    case {owner(DbName, DocId), get_json_value(deleted, Change, false)} of
     {_, true} ->
         rep_doc_deleted(DbName, DocId),
         State;
@@ -405,12 +405,11 @@ process_update(State, DbName, {Change}) ->
         end
     end.
 
-
-is_owner(<<"shards/", _/binary>>=DbName, DocId) ->
-    mem3_util:owner(mem3:dbname(DbName), DocId);
-is_owner(_, _) ->
-    true.
-
+owner(DbName, DocId) ->
+    Live = [node()|nodes()],
+    Nodes = lists:sort([N || #shard{node=N} <- mem3:shards(DbName, DocId),
+			     lists:member(N, Live)]),
+    node() =:= hd(mem3_util:rotate_list({DbName, DocId}, Nodes)).
 
 rep_db_update_error(Error, DbName, DocId) ->
     case Error of


Mime
View raw message