couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 02/03: [SQUERGE] mem3 internal replication bug fixes
Date Thu, 03 May 2018 21:06:08 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch COUCHDB-3326-clustered-purge-davisp-refactor-2
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 0a1c42de50913e34fa962759b859a8bdaf2d2ffb
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Thu May 3 16:05:13 2018 -0500

    [SQUERGE] mem3 internal replication bug fixes
---
 src/mem3/src/mem3_rep.erl | 8 ++++----
 src/mem3/src/mem3_rpc.erl | 9 ++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 88bece4..2dd8e38 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -231,13 +231,13 @@ pull_purges(#acc{} = Acc0) ->
 
     with_src_db(Acc0, fun(Db) ->
         SrcUUID = couch_db:get_uuid(Db),
-        {ok, LocalPurgeId, Infos, ThroughSeq, Remaining} =
+        {LocalPurgeId, Infos, ThroughSeq, Remaining} =
                 mem3_rpc:load_purge_infos(TgtNode, TgtDbName, SrcUUID, Count),
 
         if Infos == [] -> ok; true ->
             {ok, _} = couch_db:purge_docs(Db, Infos, [replicated_edits]),
             Body = purge_cp_body(Acc0, ThroughSeq),
-            ok = mem3_rpc:save_purge_checkpoint(
+            mem3_rpc:save_purge_checkpoint(
                     TgtNode, TgtDbName, LocalPurgeId, Body)
         end,
 
@@ -270,7 +270,7 @@ push_purges(#acc{} = Acc0) ->
                 couch_util:get_value(<<"purge_seq">>, Props);
             {not_found, _} ->
                 {ok, Oldest} = couch_db:get_oldest_purge_seq(Db),
-                Oldest
+                erlang:max(0, Oldest - 1)
         end,
 
         FoldFun = fun({PSeq, UUID, Id, Revs}, {Count, Infos, _}) ->
@@ -466,7 +466,7 @@ save_on_target(Node, Name, Docs) ->
 
 
 purge_on_target(Node, Name, PurgeInfos) ->
-    {ok, _} = mem3_rpc:purge_docs(Node, Name, PurgeInfos, [
+    mem3_rpc:purge_docs(Node, Name, PurgeInfos, [
         replicated_changes,
         full_commit,
         ?ADMIN_CTX,
diff --git a/src/mem3/src/mem3_rpc.erl b/src/mem3/src/mem3_rpc.erl
index b0b0098..ee8ece4 100644
--- a/src/mem3/src/mem3_rpc.erl
+++ b/src/mem3/src/mem3_rpc.erl
@@ -72,7 +72,7 @@ load_purge_infos(Node, DbName, SourceUUID, Count) ->
 
 save_purge_checkpoint(Node, DbName, PurgeDocId, Body) ->
     Args = [DbName, PurgeDocId, Body],
-    rexi_call(Node, {mem3_rpc, save_purge_checkpoint, Args}).
+    rexi_call(Node, {mem3_rpc, save_purge_checkpoint_rpc, Args}).
 
 
 purge_docs(Node, DbName, PurgeInfos, Options) ->
@@ -160,7 +160,7 @@ load_purge_infos_rpc(DbName, SrcUUID, BatchSize) ->
                     couch_util:get_value(<<"purge_seq">>, Props);
                 {not_found, _} ->
                     {ok, Oldest} = couch_db:get_oldest_purge_seq(Db),
-                    Oldest
+                    erlang:max(0, Oldest - 1)
             end,
             FoldFun = fun({PSeq, UUID, Id, Revs}, {Count, Infos, _}) ->
                 NewCount = Count + length(Revs),
@@ -173,7 +173,7 @@ load_purge_infos_rpc(DbName, SrcUUID, BatchSize) ->
                     couch_db:fold_purge_infos(Db, StartSeq, FoldFun, InitAcc),
             {ok, PurgeSeq} = couch_db:get_purge_seq(Db),
             Remaining = PurgeSeq - ThroughSeq,
-            rexi:reply({ok, PurgeDocId, PurgeInfos, ThroughSeq, Remaining});
+            rexi:reply({ok, {PurgeDocId, PurgeInfos, ThroughSeq, Remaining}});
         Else ->
             rexi:reply(Else)
     end.
@@ -185,8 +185,7 @@ save_purge_checkpoint_rpc(DbName, PurgeDocId, Body) ->
         {ok, Db} ->
             Doc = #doc{id = PurgeDocId, body = Body},
             Resp = try couch_db:update_doc(Db, Doc, []) of
-                {ok, _} -> ok;
-                Else -> {error, Else}
+                Resp0 -> Resp0
             catch T:R ->
                 {T, R}
             end,

-- 
To stop receiving notification emails like this one, please contact
davisp@apache.org.

Mime
View raw message