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 a768afdb8836ec7ba59fea25eef6723e1177506a
Author: Robert Newson <[email protected]>
AuthorDate: Fri May 9 17:46:46 2025 +0100

    little over-zealous wiping out uuids here
    
    need to preserve them when we can
---
 src/fabric/src/fabric_drop_seq.erl | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/fabric/src/fabric_drop_seq.erl 
b/src/fabric/src/fabric_drop_seq.erl
index 76fb6ae3f..466826cdc 100644
--- a/src/fabric/src/fabric_drop_seq.erl
+++ b/src/fabric/src/fabric_drop_seq.erl
@@ -331,15 +331,24 @@ latest_shard_sync_checkpoints(ShardSyncHistory) ->
 %% it last updated. Find these cases and split the peer checkpoints too.
 substitute_splits(Shards, PeerCheckpoints) ->
     maps:fold(
-        fun({[B1, E1], Node}, {_Uuid, Seq}, Acc) ->
+        fun({[B1, E1], Node}, {Uuid, Seq}, Acc) ->
             MatchingRanges = [
                 S#shard.range
              || #shard{range = [B2, E2]} = S <- Shards,
                 Node == S#shard.node,
                 B2 >= B1 andalso E2 =< E1
             ],
-            %% we don't know the uuids of the split shards
-            AsMap = maps:from_list([{{R, Node}, {undefined, Seq}} || R <- 
MatchingRanges]),
+            %% set uuid to undefined if ranges don't match as we don't know 
the uuids of the split shards
+            AsMap = maps:from_list([
+                {{R, Node}, {
+                    if
+                        [B1, E1] == R -> Uuid;
+                        true -> undefined
+                    end,
+                    Seq
+                }}
+             || R <- MatchingRanges
+            ]),
             maps:merge_with(fun merge_peers/3, AsMap, Acc)
         end,
         #{},

Reply via email to