You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/02/01 17:54:45 UTC

[1/3] fabric commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 3b82a96

Repository: couchdb-fabric
Updated Branches:
  refs/heads/COUCHDB-3287-pluggable-storage-engines [created] 3b82a9675


Revert "Handle no_pass message when limit is 0"

This partially reverts commit 998cf2. Only the path src/fabric_rpc.erl has
been reverted, which is 1 out of 2 files changed in the original commit.


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

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: dcfeda2b24cf3cf1e8acb0bdaaae473940f181d8
Parents: f9f5681
Author: ILYA Khlopotov <ii...@apache.org>
Authored: Thu Jan 26 10:19:27 2017 -0800
Committer: ILYA Khlopotov <ii...@apache.org>
Committed: Thu Jan 26 10:19:43 2017 -0800

----------------------------------------------------------------------
 src/fabric_rpc.erl | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/dcfeda2b/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 679a305..d2ef8a9 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -351,9 +351,7 @@ changes_enumerator(DocInfo, Acc) ->
     #doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del}|_]} = DocInfo,
     case [X || X <- couch_changes:filter(Db, DocInfo, Filter), X /= null] of
     [] ->
-        ChangesRow = {no_pass, [
-            {pending, Pending-1},
-            {seq, Seq}]};
+        ChangesRow = {no_pass, Seq};
     Results ->
         Opts = if Conflicts -> [conflicts | DocOptions]; true -> DocOptions end,
         ChangesRow = {change, [


[2/3] fabric commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 3b82a96

Posted by da...@apache.org.
Update to use new pluggable storage API


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

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 5226543783ef88db73c6fc4254875cc73892ce4f
Parents: dcfeda2
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Feb 10 16:38:41 2016 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Feb 1 11:03:40 2017 -0600

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


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/52265437/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index d2ef8a9..8aa2a8d 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -69,7 +69,7 @@ changes(DbName, Options, StartVector, DbOptions) ->
     {ok, Db} ->
         StartSeq = calculate_start_seq(Db, node(), StartVector),
         Enum = fun changes_enumerator/2,
-        Opts = [{dir,Dir}],
+        Opts = [doc_info, {dir,Dir}],
         Acc0 = #cacc{
           db = Db,
           seq = StartSeq,
@@ -80,7 +80,7 @@ changes(DbName, Options, StartVector, DbOptions) ->
         },
         try
             {ok, #cacc{seq=LastSeq, pending=Pending, epochs=Epochs}} =
-                couch_db:changes_since(Db, StartSeq, Enum, Opts, Acc0),
+                couch_db:fold_changes(Db, StartSeq, Enum, Acc0, Opts),
             rexi:stream_last({complete, [
                 {seq, {LastSeq, uuid(Db), owner_of(LastSeq, Epochs)}},
                 {pending, Pending}
@@ -217,15 +217,16 @@ get_missing_revs(DbName, IdRevsList, Options) ->
     rexi:reply(case get_or_create_db(DbName, Options) of
     {ok, Db} ->
         Ids = [Id1 || {Id1, _Revs} <- IdRevsList],
+        FullDocInfos = couch_db:open_docs(Db, Ids, [full_doc_info]),
         {ok, lists:zipwith(fun({Id, Revs}, FullDocInfoResult) ->
             case FullDocInfoResult of
-            {ok, #full_doc_info{rev_tree=RevisionTree} = FullInfo} ->
+            #full_doc_info{rev_tree=RevisionTree} = FullInfo ->
                 MissingRevs = couch_key_tree:find_missing(RevisionTree, Revs),
                 {Id, MissingRevs, possible_ancestors(FullInfo, MissingRevs)};
             not_found ->
                 {Id, Revs, []}
             end
-        end, IdRevsList, couch_btree:lookup(Db#db.id_tree, Ids))};
+        end, IdRevsList, FullDocInfos)};
     Error ->
         Error
     end).
@@ -249,8 +250,8 @@ group_info(DbName, DDocId, DbOptions) ->
 
 reset_validation_funs(DbName) ->
     case get_or_create_db(DbName, []) of
-    {ok, #db{main_pid = Pid}} ->
-        gen_server:cast(Pid, {load_validation_funs, undefined});
+    {ok, Db} ->
+        couch_db:reload_validation_funs(Db);
     _ ->
         ok
     end.
@@ -537,20 +538,6 @@ uuid_prefix_len() ->
 -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, [{epochs, [{node1, 1}]}, {uuid, <<"uuid1">>}]),
-    ?assertEqual(0, calculate_start_seq(#db{header=Hdr2}, node1, {1, <<"uuid2">>})),
-    %% 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}, node1, {2, <<"uuid1">>})),
-    %% 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}, node1, {3, <<"uuid1">>})),
-    %% return integer if we didn't get a vector.
-    ?assertEqual(4, calculate_start_seq(#db{}, foo, 4)).
-
 is_owner_test() ->
     ?assertNot(is_owner(foo, 1, [])),
     ?assertNot(is_owner(foo, 1, [{foo, 1}])),


[3/3] fabric commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 3b82a96

Posted by da...@apache.org.
Pass the storage engine option to RPC workers


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

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 3b82a9675d83341b783952aaaa58db311bbaf9c2
Parents: 5226543
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Apr 6 11:06:51 2016 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Feb 1 11:03:40 2017 -0600

----------------------------------------------------------------------
 src/fabric_db_create.erl | 29 ++++++++++++++++++-----------
 src/fabric_rpc.erl       |  6 +++---
 2 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3b82a967/src/fabric_db_create.erl
----------------------------------------------------------------------
diff --git a/src/fabric_db_create.erl b/src/fabric_db_create.erl
index a7f4ed9..3685398 100644
--- a/src/fabric_db_create.erl
+++ b/src/fabric_db_create.erl
@@ -28,7 +28,7 @@ go(DbName, Options) ->
             {error, file_exists};
         false ->
             {Shards, Doc} = generate_shard_map(DbName, Options),
-            CreateShardResult = create_shard_files(Shards),
+            CreateShardResult = create_shard_files(Shards, Options),
             case CreateShardResult of
             enametoolong ->
                 {error, {database_name_too_long, DbName}};
@@ -64,12 +64,12 @@ generate_shard_map(DbName, Options) ->
         % the DB already exists, and may have a different Suffix
         ok;
     {not_found, _} ->
-        Doc = make_document(Shards, Suffix)
+        Doc = make_document(Shards, Suffix, Options)
     end,
     {Shards, Doc}.
 
-create_shard_files(Shards) ->
-    Workers = fabric_util:submit_jobs(Shards, create_db, []),
+create_shard_files(Shards, Options) ->
+    Workers = fabric_util:submit_jobs(Shards, create_db, [Options]),
     RexiMon = fabric_util:create_monitors(Shards),
     try fabric_util:recv(Workers, #shard.ref, fun handle_message/3, Workers) of
     {error, file_exists} ->
@@ -155,7 +155,7 @@ maybe_stop(W, Counters) ->
         end
     end.
 
-make_document([#shard{dbname=DbName}|_] = Shards, Suffix) ->
+make_document([#shard{dbname=DbName}|_] = Shards, Suffix, Options) ->
     {RawOut, ByNodeOut, ByRangeOut} =
     lists:foldl(fun(#shard{node=N, range=[B,E]}, {Raw, ByNode, ByRange}) ->
         Range = ?l2b([couch_util:to_hex(<<B:32/integer>>), "-",
@@ -164,12 +164,19 @@ make_document([#shard{dbname=DbName}|_] = Shards, Suffix) ->
         {[[<<"add">>, Range, Node] | Raw], orddict:append(Node, Range, ByNode),
             orddict:append(Range, Node, ByRange)}
     end, {[], [], []}, Shards),
-    #doc{id=DbName, body = {[
-        {<<"shard_suffix">>, Suffix},
-        {<<"changelog">>, lists:sort(RawOut)},
-        {<<"by_node">>, {[{K,lists:sort(V)} || {K,V} <- ByNodeOut]}},
-        {<<"by_range">>, {[{K,lists:sort(V)} || {K,V} <- ByRangeOut]}}
-    ]}}.
+    EngineProp = case couch_util:get_value(engine, Options) of
+        E when is_binary(E) -> [{<<"engine">>, E}];
+        _ -> []
+    end,
+    #doc{
+        id = DbName,
+        body = {[
+            {<<"shard_suffix">>, Suffix},
+            {<<"changelog">>, lists:sort(RawOut)},
+            {<<"by_node">>, {[{K,lists:sort(V)} || {K,V} <- ByNodeOut]}},
+            {<<"by_range">>, {[{K,lists:sort(V)} || {K,V} <- ByRangeOut]}}
+        ] ++ EngineProp}
+    }.
 
 db_exists(DbName) -> is_list(catch mem3:shards(DbName)).
 

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3b82a967/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 8aa2a8d..eccb8c0 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -16,7 +16,7 @@
 -export([open_doc/3, open_revs/4, get_doc_info/3, get_full_doc_info/3,
     get_missing_revs/2, get_missing_revs/3, update_docs/3]).
 -export([all_docs/3, changes/3, map_view/4, reduce_view/4, group_info/2]).
--export([create_db/1, delete_db/1, reset_validation_funs/1, set_security/3,
+-export([create_db/2, delete_db/1, reset_validation_funs/1, set_security/3,
     set_revs_limit/3, create_shard_db_doc/2, delete_shard_db_doc/2]).
 -export([get_all_security/2, open_shard/2]).
 -export([compact/1, compact/2]).
@@ -143,8 +143,8 @@ fix_skip_and_limit(Args) ->
     #mrargs{skip=Skip, limit=Limit}=Args,
     Args#mrargs{skip=0, limit=Skip+Limit}.
 
-create_db(DbName) ->
-    rexi:reply(case couch_server:create(DbName, []) of
+create_db(DbName, Options) ->
+    rexi:reply(case couch_server:create(DbName, Options) of
     {ok, _} ->
         ok;
     Error ->