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: Address Paul and Ilya's comments
Date Wed, 20 Jun 2018 07:14:40 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 94fcf71  Address Paul and Ilya's comments
94fcf71 is described below

commit 94fcf717cc247fad720b4ec38e1ef7d6ae8090cc
Author: jiangphcn <jiangph@cn.ibm.com>
AuthorDate: Wed Jun 20 10:47:38 2018 +0800

    Address Paul and Ilya's comments
    
      - add error log for purge checkpoint
      - introduce version for mem3
      - use verify_module with arity 1
    
    COUCHDB-3326
---
 src/couch/src/couch_db.erl                              | 17 +++++++++++------
 src/couch_mrview/src/couch_mrview_util.erl              |  2 +-
 .../src/cpse_test_purge_bad_checkpoints.erl             |  2 +-
 src/couch_pse_tests/src/cpse_test_purge_replication.erl |  1 +
 src/couch_pse_tests/src/cpse_util.erl                   |  3 ++-
 src/mem3/src/mem3_rep.erl                               |  8 +++++---
 6 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index d0f1e21..e7b5328 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -436,8 +436,10 @@ get_minimum_purge_seq(#db{} = Db) ->
                     _ ->
                         % If there's a broken doc we have to keep every
                         % purge info until the doc is fixed or removed.
-                        Fmt = "Invalid purge doc '~s' with purge_seq '~w'",
-                        couch_log:error(Fmt, [DocId, ClientSeq]),
+                        Fmt = "Invalid purge doc '~s' on database ~p
+                            with purge_seq '~w'",
+                        DbName = couch_db:name(Db),
+                        couch_log:error(Fmt, [DocId, DbName, ClientSeq]),
                         {ok, erlang:min(OldestPurgeSeq, SeqAcc)}
                 end;
             _ ->
@@ -479,14 +481,17 @@ purge_client_exists(DbName, DocId, Props) ->
             Updated = couch_util:get_value(<<"updated_on">>, Props),
             if is_integer(Updated) and Updated > LagThreshold -> ok; true ->
                 Diff = NowSecs - Updated,
-                Fmt = "Purge checkpoint '~s' not updated in ~p seconds",
-                couch_log:error(Fmt, [DocId, Diff])
+                Fmt1 = "Purge checkpoint '~s' not updated in ~p seconds",
+                couch_log:error(Fmt1, [DocId, Diff])
             end
         end,
         Exists
     catch _:_ ->
         % If we fail to check for a client we have to assume that
         % it exists.
+        Fmt2 = "Failed to check purge checkpoint using
+            document '~p' on database ~p",
+        couch_log:error(Fmt2, [DbName, DocId]),
         true
     end.
 
@@ -504,9 +509,9 @@ get_purge_client_fun(DocId, Props) ->
     F0 = couch_util:get_value(<<"verify_function">>, Props),
     try
         F = binary_to_existing_atom(F0, latin1),
-        case erlang:function_exported(M, F, 2) of
+        case erlang:function_exported(M, F, 1) of
             true ->
-                fun M:F/2;
+                fun M:F/1;
             false ->
                 Fmt2 = "Missing exported function '~p' in '~p'
                     for purge checkpoint '~s'",
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index b470631..b274961 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -45,7 +45,7 @@
 
 get_local_purge_doc_id(Sig) ->
     Version = "v" ++ config:get("purge", "version", "1") ++ "-",
-    ?l2b(?LOCAL_DOC_PREFIX ++ "purge-" ++ Version ++ "mrview-" ++ Sig).
+    ?l2b(?LOCAL_DOC_PREFIX ++ "purge-mrview-" ++ Version ++ Sig).
 
 
 get_value_from_options(Key, Options) ->
diff --git a/src/couch_pse_tests/src/cpse_test_purge_bad_checkpoints.erl b/src/couch_pse_tests/src/cpse_test_purge_bad_checkpoints.erl
index 52d6870..3d5edb1 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_bad_checkpoints.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_bad_checkpoints.erl
@@ -96,7 +96,7 @@ save_local_doc(Db1, PurgeSeq, Mod, Fun) ->
     {Mega, Secs, _} = os:timestamp(),
     NowSecs = Mega * 1000000 + Secs,
     Doc = couch_doc:from_json_obj(?JSON_DECODE(?JSON_ENCODE({[
-        {<<"_id">>, <<"_local/purge-test-stuff">>},
+        {<<"_id">>, <<"_local/purge-test-stuff-v1">>},
         {<<"purge_seq">>, PurgeSeq},
         {<<"timestamp_utc">>, NowSecs},
         {<<"verify_module">>, Mod},
diff --git a/src/couch_pse_tests/src/cpse_test_purge_replication.erl b/src/couch_pse_tests/src/cpse_test_purge_replication.erl
index bba360a..474d4e6 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_replication.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_replication.erl
@@ -188,6 +188,7 @@ repl(Source, Target) ->
 
     SrcTerm = cpse_util:db_as_term(Source, replication),
     TgtTerm = cpse_util:db_as_term(Target, replication),
+
     Diff = cpse_util:term_diff(SrcTerm, TgtTerm),
     ?assertEqual(nodiff, Diff).
 
diff --git a/src/couch_pse_tests/src/cpse_util.erl b/src/couch_pse_tests/src/cpse_util.erl
index aa73c38..17e8e48 100644
--- a/src/couch_pse_tests/src/cpse_util.erl
+++ b/src/couch_pse_tests/src/cpse_util.erl
@@ -470,7 +470,8 @@ db_docs_as_term(Db) ->
 db_local_docs_as_term(Db, Type) ->
     FoldFun = fun(Doc, Acc) ->
         case Doc#doc.id of
-            <<"_local/purge-mem3-", _/binary>> when Type == replication ->
+            <<?LOCAL_DOC_PREFIX, "purge-mem3", _/binary>>
+                when Type == replication ->
                 {ok, Acc};
             _ ->
                 {ok, [Doc | Acc]}
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 2dd8e38..3f224cd 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -18,7 +18,7 @@
     go/3,
     make_local_id/2,
     make_purge_id/2,
-    verify_purge_checkpoint/3,
+    verify_purge_checkpoint/1,
     find_source_seq/4
 ]).
 
@@ -122,10 +122,12 @@ make_local_id(SourceThing, TargetThing, Filter) ->
 
 
 make_purge_id(SourceUUID, TargetUUID) ->
-    <<"_local/purge-mem3-", SourceUUID/binary, "-", TargetUUID/binary>>.
+    Version = "v" ++ config:get("purge", "version", "1") ++ "-",
+    ?l2b(?LOCAL_DOC_PREFIX ++ "purge-mem3-" ++ Version ++
+        ?b2l(SourceUUID) ++ "-" ++ ?b2l(TargetUUID)).
 
 
-verify_purge_checkpoint(_Db, _DocId, Props) ->
+verify_purge_checkpoint(Props) ->
     DbName = couch_util:get_value(<<"dbname">>, Props),
     SourceBin = couch_util:get_value(<<"source">>, Props),
     TargetBin = couch_util:get_value(<<"target">>, Props),


Mime
View raw message