You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/09/05 20:25:26 UTC

[couchdb] branch prototype/fdb-layer-fix-update-seq-for-local-docs updated (17b0bc9 -> 0b62f85)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch prototype/fdb-layer-fix-update-seq-for-local-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 17b0bc9  Handle update_seq for _local_docs
     new 0b62f85  Handle update_seq for _local_docs

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (17b0bc9)
            \
             N -- N -- N   refs/heads/prototype/fdb-layer-fix-update-seq-for-local-docs (0b62f85)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 test/elixir/test/basics_test.exs | 10 ++++++++++
 1 file changed, 10 insertions(+)


[couchdb] 01/01: Handle update_seq for _local_docs

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch prototype/fdb-layer-fix-update-seq-for-local-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 0b62f85faa59f03ac5d5248477fbf06e38389e3f
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Sep 5 16:03:17 2019 -0400

    Handle update_seq for _local_docs
    
    On master `_local_docs&update_seq=true` returns the update sequence of the
    database. Even though it might not make much sense since updating local docs
    doesn't bump the sequence, it's probably a good idea to stay consistent.
    
    It's also worth mentioning another inconsistency is when FDB returns a
    `total_rows` count for `_local_docs` while master returns `null`. I think
    that's probably acceptable. Master would return the count if had it available
    easily and having it seems like a useful thing and an improvement.
---
 src/fabric/src/fabric2_db.erl    | 25 ++++++++++++++-----------
 test/elixir/test/basics_test.exs | 10 ++++++++++
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index f3036e4..853b502 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -738,15 +738,7 @@ fold_docs(Db, UserFun, UserAcc0, Options) ->
             } = TxDb,
 
             Prefix = erlfdb_tuple:pack({?DB_ALL_DOCS}, DbPrefix),
-            NS = couch_util:get_value(namespace, Options),
-            DocCount = get_doc_count(TxDb, NS),
-            Meta = case lists:keyfind(update_seq, 1, Options) of
-                {_, true} ->
-                    UpdateSeq = fabric2_db:get_update_seq(TxDb),
-                    [{update_seq, UpdateSeq}];
-                _ ->
-                    []
-            end ++ [{total, DocCount}, {offset, null}],
+            Meta = get_all_docs_meta(TxDb, Options),
 
             UserAcc1 = maybe_stop(UserFun({meta, Meta}, UserAcc0)),
 
@@ -780,8 +772,7 @@ fold_local_docs(Db, UserFun, UserAcc0, Options) ->
             } = TxDb,
 
             Prefix = erlfdb_tuple:pack({?DB_LOCAL_DOCS}, DbPrefix),
-            DocCount = get_doc_count(TxDb, <<"doc_local_count">>),
-            Meta = [{total, DocCount}, {offset, null}],
+            Meta = get_all_docs_meta(TxDb, Options),
 
             UserAcc1 = maybe_stop(UserFun({meta, Meta}, UserAcc0)),
 
@@ -959,6 +950,18 @@ new_revid(Db, Doc) ->
     }.
 
 
+get_all_docs_meta(TxDb, Options) ->
+    NS = couch_util:get_value(namespace, Options),
+    DocCount = get_doc_count(TxDb, NS),
+    case lists:keyfind(update_seq, 1, Options) of
+        {_, true} ->
+            UpdateSeq = fabric2_db:get_update_seq(TxDb),
+            [{update_seq, UpdateSeq}];
+        _ ->
+            []
+    end ++ [{total, DocCount}, {offset, null}].
+
+
 maybe_set_user_ctx(Db, Options) ->
     case fabric2_util:get_value(user_ctx, Options) of
         #user_ctx{} = UserCtx ->
diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs
index cde11aa..d5deaf7 100644
--- a/test/elixir/test/basics_test.exs
+++ b/test/elixir/test/basics_test.exs
@@ -424,6 +424,11 @@ defmodule BasicsTest do
     resp = Couch.get("/#{db_name}/_design_docs?" <> qstr)
     assert resp.status_code == 200
     assert resp.body == %{"offset" => :null, "rows" => [], "total_rows" => 2}
+
+    # update_seq=true
+    resp = Couch.get("/#{db_name}/_design_docs?update_seq=true")
+    assert resp.status_code == 200
+    assert Map.has_key?(resp.body, "update_seq")
   end
 
   @tag :with_db
@@ -480,6 +485,11 @@ defmodule BasicsTest do
     resp = Couch.get("/#{db_name}/_local_docs?" <> qstr)
     assert resp.status_code == 200
     assert resp.body == %{"offset" => :null, "rows" => [], "total_rows" => 2}
+
+    # update_seq=true
+    resp = Couch.get("/#{db_name}/_local_docs?update_seq=true")
+    assert resp.status_code == 200
+    assert Map.has_key?(resp.body, "update_seq")
   end
 
 end