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 2026/09/24 16:16:07 UTC
(couchdb) branch main updated: Preserve view purge sequences when compacting
This is an automated email from the ASF dual-hosted git repository.
nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new 1582cf98c Preserve view purge sequences when compacting
1582cf98c is described below
commit 1582cf98c5ac97f701c809ee2668026ff8a9a5b1
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Thu Sep 24 02:45:58 2026 -0400
Preserve view purge sequences when compacting
Previously, the view's new state was initialized with the purge sequence of the
db. But the view might not have yet processed all the purges up until that db
purge sequence. That lead to us possibly skipping over purges in the view (the
ones that occurred right before the compaction started). To avoid that,
preserve the view's old purge sequence and carry that over to the new state.
After compaction swaps it can continue processing those purges where it left
off.
Fix: https://github.com/apache/couchdb/issues/6128
---
src/couch_mrview/src/couch_mrview_compactor.erl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/couch_mrview/src/couch_mrview_compactor.erl b/src/couch_mrview/src/couch_mrview_compactor.erl
index 4686d77eb..fa8ce71fe 100644
--- a/src/couch_mrview/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview/src/couch_mrview_compactor.erl
@@ -40,6 +40,7 @@ compact(State) ->
idx_name = IdxName,
sig = Sig,
update_seq = Seq,
+ purge_seq = PurgeSeq,
id_btree = IdBtree,
views = Views
} = State,
@@ -126,10 +127,16 @@ compact(State) ->
),
unlink(EmptyState#mrst.fd),
+ % EmptyState from reset_index/3 has the purge_seq set to db's purge
+ % sequence. However the B-trees we just copied are from the old state, and
+ % we should also carry over the old purge_seq of this view, so it can
+ % continue processsing where it left off right before the compaction
+ % started.
{ok, EmptyState#mrst{
id_btree = NewIdBtree,
views = NewViews,
- update_seq = Seq
+ update_seq = Seq,
+ purge_seq = PurgeSeq
}}.
recompact(State) ->