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

rnewson pushed a commit to branch auto-delete-3
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 0d87a13f93fe2e728d05d2c7abcb0ac1272cb354
Author: Robert Newson <[email protected]>
AuthorDate: Tue May 13 11:34:09 2025 +0100

    fixes
---
 src/fabric/src/fabric_drop_seq.erl | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/fabric/src/fabric_drop_seq.erl 
b/src/fabric/src/fabric_drop_seq.erl
index 6749b315b..d6d3b81ef 100644
--- a/src/fabric/src/fabric_drop_seq.erl
+++ b/src/fabric/src/fabric_drop_seq.erl
@@ -132,7 +132,9 @@ crossref(PeerCheckpoints0, ShardSyncHistory) ->
                 fun({R, _S, T}, History, Acc2) ->
                     case
                         lists:search(
-                            fun({SU, SS, _TU, _TS}) -> Uuid == SU andalso SS 
=< Seq end,
+                            fun({SU, SS, _TU, _TS}) ->
+                                uuids_match([Uuid, SU]) andalso SS =< Seq
+                            end,
                             History
                         )
                     of
@@ -308,10 +310,13 @@ parse_peer_checkpoint_docs_cb(_Else, Acc) ->
 merge_peers(_Key, {Uuid1, Val1}, {Uuid2, Val2}) when
     is_binary(Uuid1), is_binary(Uuid2), is_integer(Val1), is_integer(Val2)
 ->
-    PrefixLen = min(byte_size(Uuid1), byte_size(Uuid2)),
-    true = binary:longest_common_prefix([Uuid1, Uuid2]) == PrefixLen,
+    true = uuids_match([Uuid1, Uuid2]),
     {Uuid1, min(Val1, Val2)}.
 
+uuids_match(Uuids) when is_list(Uuids) ->
+    PrefixLen = lists:min([byte_size(Uuid) || Uuid <- Uuids]),
+    binary:longest_common_prefix(Uuids) == PrefixLen.
+
 decode_seq(OpaqueSeq) ->
     Decoded = fabric_view_changes:decode_seq(OpaqueSeq),
     lists:foldl(
@@ -817,9 +822,9 @@ go_int2_test_() ->
     [
         ?_assertEqual(
             #{
-                {Subrange1, Node1} => {<<"s1n1">>, 11},
-                {Subrange2, Node1} => {<<"s2n1">>, 11},
-                {Subrange1, Node1} => {<<"s2n1">>, 11},
+                {Subrange1, Node1} => {<<"s1n1">>, 12},
+                {Subrange2, Node1} => {<<"s2n1">>, 12},
+                {Subrange1, Node2} => {<<"s1n2">>, 11},
                 {Subrange2, Node2} => {<<"s2n2">>, 11}
             },
             element(

Reply via email to