You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/01 11:11:51 UTC

[03/50] fabric commit: updated refs/heads/windsor-merge-121 to 79e6e2f

Revert uuid in changes feeds temporarily

Reverts;
b271bcceff4dddc255af3e4ae57a1a36d6708b8a 19133-fix-code-upgrade
7102f90a85c80b02229a429185b40817182fbfcb 18726-use-uuid-generation-in-since


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/9aafe7b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/9aafe7b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/9aafe7b3

Branch: refs/heads/windsor-merge-121
Commit: 9aafe7b39069fc8c1534becf8fd434a717bab07f
Parents: 518f76d
Author: Robert Newson <ro...@cloudant.com>
Authored: Tue Jul 30 23:23:23 2013 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Jul 31 10:51:10 2014 +0100

----------------------------------------------------------------------
 src/fabric_rpc.erl | 70 +++++--------------------------------------------
 1 file changed, 7 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/9aafe7b3/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 870ac57..c6ac263 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -29,19 +29,18 @@
 
 changes(DbName, #changes_args{} = Args, StartSeq) ->
     changes(DbName, [Args], StartSeq);
-changes(DbName, Options, StartVector) ->
+changes(DbName, Options, StartSeq) ->
     erlang:put(io_priority, {interactive, DbName}),
     #changes_args{dir=Dir} = Args = lists:keyfind(changes_args, 1, Options),
     case get_or_create_db(DbName, []) of
     {ok, Db} ->
-        StartSeq = calculate_start_seq(Db, StartVector),
         Enum = fun changes_enumerator/2,
         Opts = [{dir,Dir}],
         Acc0 = {Db, StartSeq, Args, Options},
         try
             {ok, {_, LastSeq, _, _}} =
                 couch_db:changes_since(Db, StartSeq, Enum, Opts, Acc0),
-            rexi:reply({complete, {LastSeq, couch_db:get_uuid(Db), node()}})
+            rexi:reply({complete, LastSeq})
         after
             couch_db:close(Db)
         end;
@@ -279,14 +278,11 @@ changes_enumerator(DocInfo, {Db, _Seq, Args, Options}) ->
 
 changes_row(Db, #doc_info{id=Id, high_seq=Seq}=DI, Results, Del, true, Opts) ->
     Doc = doc_member(Db, DI, Opts),
-    Uuid = couch_db:get_uuid(Db),
-    #change{key={Seq, Uuid, node()}, id=Id, value=Results, doc=Doc, deleted=Del};
-changes_row(Db, #doc_info{id=Id, high_seq=Seq}, Results, true, _, _) ->
-    Uuid = couch_db:get_uuid(Db),
-    #change{key={Seq, Uuid, node()}, id=Id, value=Results, deleted=true};
-changes_row(Db, #doc_info{id=Id, high_seq=Seq}, Results, _, _, _) ->
-    Uuid = couch_db:get_uuid(Db),
-    #change{key={Seq, Uuid, node()}, id=Id, value=Results}.
+    #change{key=Seq, id=Id, value=Results, doc=Doc, deleted=Del};
+changes_row(_, #doc_info{id=Id, high_seq=Seq}, Results, true, _, _) ->
+    #change{key=Seq, id=Id, value=Results, deleted=true};
+changes_row(_, #doc_info{id=Id, high_seq=Seq}, Results, _, _, _) ->
+    #change{key=Seq, id=Id, value=Results}.
 
 doc_member(Shard, DocInfo, Opts) ->
     case couch_db:open_doc(Shard, DocInfo, [deleted | Opts]) of
@@ -367,55 +363,3 @@ set_io_priority(DbName, Options) ->
         _ ->
             ok
     end.
-
-calculate_start_seq(_Db, Seq) when is_integer(Seq) ->
-    Seq;
-calculate_start_seq(Db, {Seq, Uuid, Node}) ->
-    case couch_db:get_uuid(Db) == Uuid of
-        true ->
-            case owner(Node, Seq, couch_db:get_epochs(Db)) of
-                true -> Seq;
-                false -> 0
-            end;
-        false ->
-            %% The file was rebuilt, most likely in a different
-            %% order, so rewind.
-            0
-    end.
-
-owner(Node, Seq, Epochs) ->
-    owner(Node, Seq, Epochs, infinity).
-
-owner(_Node, _Seq, [], _HighSeq) ->
-    false;
-owner(Node, Seq, [{EpochNode, EpochSeq} | _Rest], HighSeq)
-  when Node =:= EpochNode andalso Seq < HighSeq andalso Seq >= EpochSeq ->
-    true;
-owner(Node, Seq, [{_EpochNode, EpochSeq} | Rest], _HighSeq) ->
-    owner(Node, Seq, Rest, EpochSeq).
-
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
-
-calculate_start_seq_test() ->
-    %% uuid mismatch is always a rewind.
-    Hdr1 = couch_db_header:new(),
-    Hdr2 = couch_db_header:set(Hdr1, [{uuid, uuid1}]),
-    ?assertEqual(0, calculate_start_seq(#db{header=Hdr2}, {1, uuid2, node1})),
-    %% uuid matches and seq is owned by node.
-    Hdr3 = couch_db_header:set(Hdr2, [{epochs, [{node1, 1}]}]),
-    ?assertEqual(2, calculate_start_seq(#db{header=Hdr3}, {2, uuid1, node1})),
-    %% uuids match but seq is not owned by node.
-    Hdr4 = couch_db_header:set(Hdr2, [{epochs, [{node2, 2}, {node1, 1}]}]),
-    ?assertEqual(0, calculate_start_seq(#db{header=Hdr4}, {3, uuid1, node1})),
-    %% return integer if we didn't get a vector.
-    ?assertEqual(4, calculate_start_seq(#db{}, 4)).
-
-owner_test() ->
-    ?assertNot(owner(foo, 1, [])),
-    ?assert(owner(foo, 1, [{foo, 1}])),
-    ?assert(owner(foo, 50, [{bar, 100}, {foo, 1}])),
-    ?assert(owner(foo, 50, [{baz, 200}, {bar, 100}, {foo, 1}])),
-    ?assert(owner(bar, 150, [{baz, 200}, {bar, 100}, {foo, 1}])).
-
--endif.