This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch vdu-update-discrepancy
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7b22225e583dbc05c8f742e41946e907b3d61c60
Author: Robert Newson <[email protected]>
AuthorDate: Thu Oct 15 11:26:28 2026 +0100

    we skipped necessary logic in the IsOldLeaf case
    
    revise this section to do all the necessary logic except
    the VDU callback when no VDU is present.
    
    fixes https://github.com/apache/couchdb/issues/6162
---
 src/couch/src/couch_db.erl | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index e22f070b7..04ba8bf01 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -1237,14 +1237,13 @@ prep_and_validate_replicated_updates(
                     fun(#doc{id = Id, revs = {Pos, [RevId | _]}} = Doc, 
{AccValidated, AccErrors2}) ->
                         IsOldLeaf = lists:member({Pos, RevId}, OldLeafsLU),
                         case dict:find({Pos, RevId}, LeafRevsFullDict) of
-                            {ok, {Start, Path}} when not IsOldLeaf ->
-                                % our unflushed doc is a leaf node. Go back on 
the path
-                                % to find the previous rev that's on disk.
-
-                                LoadPrevRevFun = fun() ->
-                                    make_first_doc_on_disk(Db, Id, Start - 1, 
tl(Path))
+                            {ok, {Start, Path}} ->
+                                LoadPrevRevFun = fun
+                                    () when IsOldLeaf ->
+                                        make_first_doc_on_disk(Db, Id, Start, 
tl(Path));
+                                    () ->
+                                        make_first_doc_on_disk(Db, Id, Start - 
1, tl(Path))
                                 end,
-
                                 case couch_doc:has_stubs(Doc) of
                                     true ->
                                         DiskDoc =
@@ -1268,9 +1267,7 @@ prep_and_validate_replicated_updates(
                                     Error ->
                                         {AccValidated, [{Doc, Error} | 
AccErrors2]}
                                 end;
-                            _ ->
-                                % this doc isn't a leaf or already exists in 
the tree.
-                                % ignore but consider it a success.
+                            error ->
                                 {AccValidated, AccErrors2}
                         end
                     end,

Reply via email to