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 31b2f53da0b51ce3d3da02d0f8afc8c8c2885e27 Author: Robert Newson <[email protected]> AuthorDate: Thu May 29 17:41:01 2025 +0100 bug fixes for issues found by PropCheck --- src/couch/src/couch_bt_engine.erl | 2 +- src/fabric/src/fabric_drop_seq.erl | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl index 9d3c97fd7..5e001d0b0 100644 --- a/src/couch/src/couch_bt_engine.erl +++ b/src/couch/src/couch_bt_engine.erl @@ -820,7 +820,7 @@ set_update_seq(#st{header = Header} = St, UpdateSeq) -> }}. set_drop_seq(#st{header = Header} = St, ExpectedUuidPrefix, NewDropSeq) when - is_binary(ExpectedUuidPrefix), is_integer(NewDropSeq), NewDropSeq > 0 + is_binary(ExpectedUuidPrefix), is_integer(NewDropSeq), NewDropSeq >= 0 -> CurrentDropSeq = get_drop_seq(St), Uuid = get_uuid(St), diff --git a/src/fabric/src/fabric_drop_seq.erl b/src/fabric/src/fabric_drop_seq.erl index 50556008c..b372aa6a0 100644 --- a/src/fabric/src/fabric_drop_seq.erl +++ b/src/fabric/src/fabric_drop_seq.erl @@ -163,7 +163,25 @@ crossref(PeerCheckpoints0, ShardSyncHistory) -> %% crossreferences may be possible. if PeerCheckpoints0 == PeerCheckpoints1 -> - PeerCheckpoints1; + %% insert {<<>>, 0} for any missing crossref so that shard sync + %% history is subordinate. + maps:fold( + fun({Range, Node}, {_Uuid, _Seq}, Acc1) -> + Others = maps:filter( + fun({R, _S, T}, _History) -> R == Range andalso T /= Node end, + ShardSyncHistory + ), + maps:fold( + fun({R, _S, T}, _History, Acc3) -> + maps:merge(#{{R, T} => {<<>>, 0}}, Acc3) + end, + Acc1, + Others + ) + end, + PeerCheckpoints1, + PeerCheckpoints1 + ); true -> crossref(PeerCheckpoints1, ShardSyncHistory) end. @@ -333,7 +351,7 @@ decode_seq(OpaqueSeq) -> is_integer(Seq), S >= 0, E > S, - Seq > 0, + Seq >= 0, is_binary(Uuid), is_atom(Node) ->
