couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiangp...@apache.org
Subject [couchdb] branch COUCHDB-3326-clustered-purge-pr5-implementation updated: Modify return code from get_purge_seq/1 and get_oldest_purge_seq/1
Date Thu, 28 Jun 2018 06:16:16 GMT
This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch COUCHDB-3326-clustered-purge-pr5-implementation
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/COUCHDB-3326-clustered-purge-pr5-implementation
by this push:
     new 1dae6af  Modify return code from get_purge_seq/1 and get_oldest_purge_seq/1
1dae6af is described below

commit 1dae6af0a309b7d0ee40bfb354521f8999bce6f8
Author: jiangphcn <jiangph@cn.ibm.com>
AuthorDate: Thu Jun 28 14:15:29 2018 +0800

    Modify return code from get_purge_seq/1 and get_oldest_purge_seq/1
    
    COUCHDB-3326
---
 src/couch/src/couch_db.erl                         |  4 ++--
 src/couch/src/couch_httpd_db.erl                   |  2 +-
 src/couch/test/couch_bt_engine_upgrade_tests.erl   | 24 +++++++++++-----------
 src/couch_index/src/couch_index_updater.erl        |  4 ++--
 src/couch_mrview/src/couch_mrview_index.erl        |  2 +-
 src/couch_mrview/src/couch_mrview_util.erl         |  4 ++--
 .../test/couch_mrview_purge_docs_tests.erl         |  4 ++--
 src/couch_pse_tests/src/cpse_util.erl              |  2 +-
 src/fabric/src/fabric_rpc.erl                      |  2 +-
 src/mem3/src/mem3_rep.erl                          |  8 ++++----
 src/mem3/src/mem3_rpc.erl                          |  4 ++--
 11 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index b3f0269..af10df3 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -519,10 +519,10 @@ get_user_ctx(?OLD_DB_REC = Db) ->
     ?OLD_DB_USER_CTX(Db).
 
 get_purge_seq(#db{}=Db) ->
-    {ok, couch_db_engine:get_purge_seq(Db)}.
+    couch_db_engine:get_purge_seq(Db).
 
 get_oldest_purge_seq(#db{}=Db) ->
-    {ok, couch_db_engine:get_oldest_purge_seq(Db)}.
+    couch_db_engine:get_oldest_purge_seq(Db).
 
 get_purge_infos_limit(#db{}=Db) ->
     couch_db_engine:get_purge_infos_limit(Db).
diff --git a/src/couch/src/couch_httpd_db.erl b/src/couch/src/couch_httpd_db.erl
index a93cbb9..81209d9 100644
--- a/src/couch/src/couch_httpd_db.erl
+++ b/src/couch/src/couch_httpd_db.erl
@@ -390,7 +390,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_purge">>]}=Req,
Db) ->
     end, IdRevs, Replies),
 
     {ok, Db2} = couch_db:reopen(Db),
-    {ok, PurgeSeq} = couch_db:get_purge_seq(Db2),
+    PurgeSeq = couch_db:get_purge_seq(Db2),
     send_json(Req, 200, {[{purge_seq, PurgeSeq}, {purged, {Results}}]});
 
 db_req(#httpd{path_parts=[_,<<"_purge">>]}=Req, _Db) ->
diff --git a/src/couch/test/couch_bt_engine_upgrade_tests.erl b/src/couch/test/couch_bt_engine_upgrade_tests.erl
index 8c748f8..1d2a86d 100644
--- a/src/couch/test/couch_bt_engine_upgrade_tests.erl
+++ b/src/couch/test/couch_bt_engine_upgrade_tests.erl
@@ -67,7 +67,7 @@ t_upgrade_without_purge_req() ->
         DbName = <<"db_without_purge_req">>,
 
         {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
-            ?assertEqual({ok, 0}, couch_db:get_purge_seq(Db)),
+            ?assertEqual(0, couch_db:get_purge_seq(Db)),
             couch_db:fold_purge_infos(Db, 0, fun fold_fun/2, [])
         end),
         ?assertEqual([], UpgradedPurged),
@@ -79,7 +79,7 @@ t_upgrade_without_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 5}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 0}, couch_db:get_purge_seq(Db))
+            ?assertEqual(0, couch_db:get_purge_seq(Db))
         end),
 
         PurgeReqs = [
@@ -93,7 +93,7 @@ t_upgrade_without_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 1}, couch_db:get_purge_seq(Db))
+            ?assertEqual(1, couch_db:get_purge_seq(Db))
         end)
     end).
 
@@ -105,7 +105,7 @@ t_upgrade_with_1_purge_req() ->
         DbName = <<"db_with_1_purge_req">>,
 
         {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
-            ?assertEqual({ok, 1}, couch_db:get_purge_seq(Db)),
+            ?assertEqual(1, couch_db:get_purge_seq(Db)),
             couch_db:fold_purge_infos(Db, 0, fun fold_fun/2, [])
         end),
         ?assertEqual([{1, <<"doc1">>}], UpgradedPurged),
@@ -117,7 +117,7 @@ t_upgrade_with_1_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 1}, couch_db:get_purge_seq(Db))
+            ?assertEqual(1, couch_db:get_purge_seq(Db))
         end),
 
         PurgeReqs = [
@@ -131,7 +131,7 @@ t_upgrade_with_1_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 2}, couch_db:get_purge_seq(Db))
+            ?assertEqual(2, couch_db:get_purge_seq(Db))
         end)
     end).
 
@@ -143,7 +143,7 @@ t_upgrade_with_N_purge_req() ->
         DbName = <<"db_with_2_purge_req">>,
 
         {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
-            ?assertEqual({ok, 2}, couch_db:get_purge_seq(Db)),
+            ?assertEqual(2, couch_db:get_purge_seq(Db)),
             couch_db:fold_purge_infos(Db, 1, fun fold_fun/2, [])
         end),
         ?assertEqual([{2, <<"doc2">>}], UpgradedPurged),
@@ -153,7 +153,7 @@ t_upgrade_with_N_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 2}, couch_db:get_purge_seq(Db))
+            ?assertEqual(2, couch_db:get_purge_seq(Db))
         end),
 
         PurgeReqs = [
@@ -167,7 +167,7 @@ t_upgrade_with_N_purge_req() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 2}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 3}, couch_db:get_purge_seq(Db))
+            ?assertEqual(3, couch_db:get_purge_seq(Db))
         end)
     end).
 
@@ -180,7 +180,7 @@ t_upgrade_with_1_purge_req_for_2_docs() ->
         DbName = <<"db_with_1_purge_req_for_2_docs">>,
 
         {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
-            ?assertEqual({ok, 3}, couch_db:get_purge_seq(Db)),
+            ?assertEqual(3, couch_db:get_purge_seq(Db)),
             couch_db:fold_purge_infos(Db, 1, fun fold_fun/2, [])
         end),
         ?assertEqual([{3,<<"doc2">>},{2,<<"doc3">>}], UpgradedPurged),
@@ -190,7 +190,7 @@ t_upgrade_with_1_purge_req_for_2_docs() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 3}, couch_db:get_purge_seq(Db))
+            ?assertEqual(3, couch_db:get_purge_seq(Db))
         end),
 
         PurgeReqs = [
@@ -204,7 +204,7 @@ t_upgrade_with_1_purge_req_for_2_docs() ->
 
         couch_util:with_db(DbName, fun(Db) ->
             ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
-            ?assertEqual({ok, 4}, couch_db:get_purge_seq(Db))
+            ?assertEqual(4, couch_db:get_purge_seq(Db))
         end)
     end).
 
diff --git a/src/couch_index/src/couch_index_updater.erl b/src/couch_index/src/couch_index_updater.erl
index 73361a9..7864bde 100644
--- a/src/couch_index/src/couch_index_updater.erl
+++ b/src/couch_index/src/couch_index_updater.erl
@@ -209,7 +209,7 @@ update(Idx, Mod, IdxState) ->
 
 
 purge_index(Db, Mod, IdxState) ->
-    {ok, DbPurgeSeq} = couch_db:get_purge_seq(Db),
+    DbPurgeSeq = couch_db:get_purge_seq(Db),
     IdxPurgeSeq = Mod:get(purge_seq, IdxState),
     if IdxPurgeSeq == DbPurgeSeq -> {ok, IdxState}; true ->
         FoldFun = fun({PurgeSeq, _UUId, Id, Revs}, Acc) ->
@@ -232,6 +232,6 @@ purge_index(Db, Mod, IdxState) ->
 
 
 count_pending_purged_docs_since(Db, Mod, IdxState) ->
-    {ok, DbPurgeSeq} = couch_db:get_purge_seq(Db),
+    DbPurgeSeq = couch_db:get_purge_seq(Db),
     IdxPurgeSeq = Mod:get(purge_seq, IdxState),
     DbPurgeSeq - IdxPurgeSeq.
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index caf4f0c..12e0e1d 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -288,7 +288,7 @@ ensure_local_purge_doc(Db, #mrst{}=State) ->
 
 
 create_local_purge_doc(Db, State) ->
-    {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+    PurgeSeq = couch_db:get_purge_seq(Db),
     update_local_purge_doc(Db, State, PurgeSeq).
 
 
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index a9ae661..fe50662 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -231,7 +231,7 @@ extract_view(Lang, #mrargs{view_type=red}=Args, Name, [View | Rest]) ->
 view_sig(Db, State, View, #mrargs{include_docs=true}=Args) ->
     BaseSig = view_sig(Db, State, View, Args#mrargs{include_docs=false}),
     UpdateSeq = couch_db:get_update_seq(Db),
-    {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+    PurgeSeq = couch_db:get_purge_seq(Db),
     #mrst{
         seq_indexed=SeqIndexed,
         keyseq_indexed=KeySeqIndexed
@@ -265,7 +265,7 @@ view_sig_term(BaseSig, UpdateSeq, PurgeSeq, KeySeqIndexed, SeqIndexed,
Args) ->
 
 
 init_state(Db, Fd, #mrst{views=Views}=State, nil) ->
-    {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+    PurgeSeq = couch_db:get_purge_seq(Db),
     Header = #mrheader{
         seq=0,
         purge_seq=PurgeSeq,
diff --git a/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl b/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
index a7fb34f..eb180b0 100644
--- a/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
+++ b/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
@@ -336,7 +336,7 @@ test_purge_compact_for_stale_purge_cp_without_client(Db) ->
 
         % check the remaining purge requests in purge tree
         {ok, Db4} = couch_db:reopen(Db3),
-        {ok, OldestPSeq} = couch_db:get_oldest_purge_seq(Db4),
+        OldestPSeq = couch_db:get_oldest_purge_seq(Db4),
         {ok, PurgedIdRevs2} = couch_db:fold_purge_infos(
                 Db4,
                 OldestPSeq - 1,
@@ -404,7 +404,7 @@ test_purge_compact_for_stale_purge_cp_with_client(Db) ->
 
         % check the remaining purge requests in purge tree
         {ok, Db4} = couch_db:reopen(Db3),
-        {ok, OldestPSeq} = couch_db:get_oldest_purge_seq(Db4),
+        OldestPSeq = couch_db:get_oldest_purge_seq(Db4),
         {ok, PurgedIdRevs2} = couch_db:fold_purge_infos(
                 Db4,
                 OldestPSeq - 1,
diff --git a/src/couch_pse_tests/src/cpse_util.erl b/src/couch_pse_tests/src/cpse_util.erl
index 17e8e48..f0afe72 100644
--- a/src/couch_pse_tests/src/cpse_util.erl
+++ b/src/couch_pse_tests/src/cpse_util.erl
@@ -214,7 +214,7 @@ assert_each_prop(Db, [{changes, Expect} | Rest]) ->
     ?assertEqual(Expect, NumChanges),
     assert_each_prop(Db, Rest);
 assert_each_prop(Db, [{purge_seq, Expect} | Rest]) ->
-    {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+    PurgeSeq = couch_db:get_purge_seq(Db),
     ?assertEqual(Expect, PurgeSeq),
     assert_each_prop(Db, Rest);
 assert_each_prop(Db, [{purge_infos, Expect} | Rest]) ->
diff --git a/src/fabric/src/fabric_rpc.erl b/src/fabric/src/fabric_rpc.erl
index dff2d7f..d8a38ba 100644
--- a/src/fabric/src/fabric_rpc.erl
+++ b/src/fabric/src/fabric_rpc.erl
@@ -349,7 +349,7 @@ read_repair_filter(Db, Docs, NodeRevs) ->
     Nodes = lists:usort([Node || {Node, _} <- NodeRevs, Node /= node()]),
     NodeSeqs = get_node_seqs(Db, Nodes),
 
-    {ok, DbPSeq} = couch_db:get_purge_seq(Db),
+    DbPSeq = couch_db:get_purge_seq(Db),
     Lag = config:get_integer("couchdb", "read_repair_lag", 100),
 
     % Filter out read-repair updates from any node that is
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 3a4147e..5a74019 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -248,8 +248,8 @@ pull_purges(#acc{} = Acc0) ->
         end,
 
         if Remaining =< 0 -> ok; true ->
-            {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
-            {ok, OldestPurgeSeq} = couch_db:get_oldest_purge_seq(Db),
+            PurgeSeq = couch_db:get_purge_seq(Db),
+            OldestPurgeSeq = couch_db:get_oldest_purge_seq(Db),
             PurgesToPush = PurgeSeq - OldestPurgeSeq,
             Changes = couch_db:count_changes_since(Db, UpdateSeq),
             throw({finished, Remaining + PurgesToPush + Changes})
@@ -276,7 +276,7 @@ push_purges(#acc{} = Acc0) ->
             {ok, #doc{body = {Props}}} ->
                 couch_util:get_value(<<"purge_seq">>, Props);
             {not_found, _} ->
-                {ok, Oldest} = couch_db:get_oldest_purge_seq(Db),
+                Oldest = couch_db:get_oldest_purge_seq(Db),
                 erlang:max(0, Oldest - 1)
         end,
 
@@ -299,7 +299,7 @@ push_purges(#acc{} = Acc0) ->
             {ok, _} = couch_db:update_doc(Db, Doc, [])
         end,
 
-        {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+        PurgeSeq = couch_db:get_purge_seq(Db),
         if ThroughSeq >= PurgeSeq -> ok; true ->
             Remaining = PurgeSeq - ThroughSeq,
             Changes = couch_db:count_changes_since(Db, UpdateSeq),
diff --git a/src/mem3/src/mem3_rpc.erl b/src/mem3/src/mem3_rpc.erl
index ee8ece4..35d1d0a 100644
--- a/src/mem3/src/mem3_rpc.erl
+++ b/src/mem3/src/mem3_rpc.erl
@@ -159,7 +159,7 @@ load_purge_infos_rpc(DbName, SrcUUID, BatchSize) ->
                 {ok, #doc{body = {Props}}} ->
                     couch_util:get_value(<<"purge_seq">>, Props);
                 {not_found, _} ->
-                    {ok, Oldest} = couch_db:get_oldest_purge_seq(Db),
+                    Oldest = couch_db:get_oldest_purge_seq(Db),
                     erlang:max(0, Oldest - 1)
             end,
             FoldFun = fun({PSeq, UUID, Id, Revs}, {Count, Infos, _}) ->
@@ -171,7 +171,7 @@ load_purge_infos_rpc(DbName, SrcUUID, BatchSize) ->
             InitAcc = {0, [], StartSeq},
             {ok, {_, PurgeInfos, ThroughSeq}} =
                     couch_db:fold_purge_infos(Db, StartSeq, FoldFun, InitAcc),
-            {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
+            PurgeSeq = couch_db:get_purge_seq(Db),
             Remaining = PurgeSeq - ThroughSeq,
             rexi:reply({ok, {PurgeDocId, PurgeInfos, ThroughSeq, Remaining}});
         Else ->


Mime
View raw message