couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couch-index commit: updated refs/heads/COUCHDB-3326-clustered-purge to b56faf3 [Forced Update!]
Date Wed, 15 Mar 2017 22:48:22 GMT
Repository: couchdb-couch-index
Updated Branches:
  refs/heads/COUCHDB-3326-clustered-purge 79b45e1c1 -> b56faf318 (forced update)


Update couch_index to use new purge API

COUCHDB-3326


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

Branch: refs/heads/COUCHDB-3326-clustered-purge
Commit: b56faf318f4e867846570f3b0006a96afd21f7ba
Parents: 4e779f2
Author: Mayya Sharipova <mayyas@ca.ibm.com>
Authored: Mon Aug 15 09:37:05 2016 -0400
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Mar 15 17:48:10 2017 -0500

----------------------------------------------------------------------
 src/couch_index_updater.erl | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/b56faf31/src/couch_index_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_updater.erl b/src/couch_index_updater.erl
index bf31460..6cc720e 100644
--- a/src/couch_index_updater.erl
+++ b/src/couch_index_updater.erl
@@ -133,10 +133,7 @@ update(Idx, Mod, IdxState) ->
         DbUpdateSeq = couch_db:get_update_seq(Db),
         DbCommittedSeq = couch_db:get_committed_update_seq(Db),
 
-        PurgedIdxState = case purge_index(Db, Mod, IdxState) of
-            {ok, IdxState0} -> IdxState0;
-            reset -> exit({reset, self()})
-        end,
+        {ok, PurgedIdxState} = purge_index(Db, Mod, IdxState),
 
         NumChanges = couch_db:count_changes_since(Db, CurrSeq),
 
@@ -201,11 +198,19 @@ purge_index(Db, Mod, IdxState) ->
     {ok, DbPurgeSeq} = couch_db:get_purge_seq(Db),
     IdxPurgeSeq = Mod:get(purge_seq, IdxState),
     if
-        DbPurgeSeq == IdxPurgeSeq ->
+        IdxPurgeSeq == DbPurgeSeq ->
             {ok, IdxState};
-        DbPurgeSeq == IdxPurgeSeq + 1 ->
-            {ok, PurgedIdRevs} = couch_db:get_last_purged(Db),
-            Mod:purge(Db, DbPurgeSeq, PurgedIdRevs, IdxState);
         true ->
-            reset
+            FoldFun = fun({PurgeSeq, _UUId, Id, Revs}, Acc) ->
+                Mod:purge(Db, PurgeSeq, [{Id, Revs}], Acc)
+            end,
+            {ok, NewStateAcc} = couch_db:fold_purged_docs(
+                    Db,
+                    IdxPurgeSeq,
+                    FoldFun,
+                    IdxState,
+                    []
+                ),
+            Mod:update_local_purge_doc(Db, NewStateAcc),
+            {ok, NewStateAcc}
     end.


Mime
View raw message