set initial peer checkpoints to zero
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl index 3a36516..0f91763 100644 --- a/src/couch/src/couch_bt_engine.erl +++ b/src/couch/src/couch_bt_engine.erl
@@ -815,17 +815,14 @@ }}. 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), ActualUuidPrefix = binary:part(Uuid, 0, byte_size(ExpectedUuidPrefix)), if ExpectedUuidPrefix /= ActualUuidPrefix -> {error, uuid_mismatch}; - NewDropSeq < CurrentDropSeq -> - {error, {drop_seq_cant_decrease, CurrentDropSeq, NewDropSeq}}; true -> NewSt = St#st{ header = couch_bt_engine_header:set(Header, [
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl index 5ec8954..26718c5 100644 --- a/src/couch_mrview/src/couch_mrview_index.erl +++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -315,8 +315,7 @@ State#mrst.db_name, <<"mrview">>, State#mrst.idx_name, - fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, couch_util:to_hex_bin(State#mrst.sig)), - State#mrst.update_seq + fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, couch_util:to_hex_bin(State#mrst.sig)) ). create_local_purge_doc(Db, State) ->
diff --git a/src/couch_replicator/src/couch_replicator_scheduler_job.erl b/src/couch_replicator/src/couch_replicator_scheduler_job.erl index add67ac..82c028a 100644 --- a/src/couch_replicator/src/couch_replicator_scheduler_job.erl +++ b/src/couch_replicator/src/couch_replicator_scheduler_job.erl
@@ -678,7 +678,7 @@ StartSeq = {0, StartSeq1}, SourceSeq = get_value(<<"update_seq">>, SourceInfo, ?LOWEST_SEQ), - create_peer_checkpoint_doc_if_missing(Source, BaseId, SourceSeq), + create_peer_checkpoint_doc_if_missing(Source, BaseId), #doc{body = {CheckpointHistory}} = SourceLog, State = #rep_state{ @@ -914,14 +914,14 @@ >>} end. -create_peer_checkpoint_doc_if_missing(#httpdb{} = Db, BaseId, SourceSeq) when - is_list(BaseId), is_binary(SourceSeq) +create_peer_checkpoint_doc_if_missing(#httpdb{} = Db, BaseId) when + is_list(BaseId) -> case couch_replicator_api_wrap:open_doc(Db, peer_checkpoint_id(BaseId), []) of {ok, _} -> ok; {error, <<"not_found">>} -> - Doc = peer_checkpoint_doc(Db, BaseId, SourceSeq), + Doc = peer_checkpoint_doc(Db, BaseId, <<"0">>), case couch_replicator_api_wrap:update_doc(Db, Doc, []) of {ok, _} -> ok;
diff --git a/src/dreyfus/src/dreyfus_index.erl b/src/dreyfus/src/dreyfus_index.erl index c2b6fa6..7f4ce84 100644 --- a/src/dreyfus/src/dreyfus_index.erl +++ b/src/dreyfus/src/dreyfus_index.erl
@@ -128,8 +128,7 @@ DbName, <<"search">>, <<(Index#index.ddoc_id)/binary, "/", (Index#index.name)/binary>>, - fabric_drop_seq:peer_id_from_sig(DbName, Index#index.sig), - Seq + fabric_drop_seq:peer_id_from_sig(DbName, Index#index.sig) ), proc_lib:init_ack({ok, self()}), gen_server:enter_loop(?MODULE, [], State);
diff --git a/src/fabric/src/fabric_drop_seq.erl b/src/fabric/src/fabric_drop_seq.erl index 41a915d..db9ea46 100644 --- a/src/fabric/src/fabric_drop_seq.erl +++ b/src/fabric/src/fabric_drop_seq.erl
@@ -8,7 +8,7 @@ -export([go/1]). -export([ - create_peer_checkpoint_doc_if_missing/5, + create_peer_checkpoint_doc_if_missing/4, update_peer_checkpoint_doc/5, cleanup_peer_checkpoint_docs/3, peer_checkpoint_doc/4, @@ -82,6 +82,10 @@ end. -spec calculate_drop_seqs(peer_checkpoints(), shard_sync_history()) -> peer_checkpoints(). +calculate_drop_seqs(reset, ShardSyncHistory) -> + maps:map( + fun(_Key, {Uuid, _Seq}) -> {Uuid, 0} end, latest_shard_sync_checkpoints(ShardSyncHistory) + ); calculate_drop_seqs(PeerCheckpoints0, ShardSyncHistory) -> ShardSyncCheckpoints = latest_shard_sync_checkpoints(ShardSyncHistory), PeerCheckpoints1 = maps:merge_with(fun merge_peers/3, PeerCheckpoints0, ShardSyncCheckpoints), @@ -232,6 +236,8 @@ case couch_util:get_value(<<"update_seq">>, Props) of undefined -> {ok, PeerCheckpoints0}; + <<"0">> -> + {stop, reset}; UpdateSeq -> {ok, maps:merge_with( @@ -301,18 +307,11 @@ ShardSyncHistory ). -create_peer_checkpoint_doc_if_missing(DbName, Subtype, Source, PeerId, UpdateSeq) when - is_binary(DbName), is_binary(PeerId), is_integer(UpdateSeq) --> - create_peer_checkpoint_doc_if_missing( - DbName, Subtype, Source, PeerId, pack_seq(DbName, UpdateSeq) - ); -create_peer_checkpoint_doc_if_missing(DbName, Subtype, Source, PeerId, UpdateSeq) when +create_peer_checkpoint_doc_if_missing(DbName, Subtype, Source, PeerId) when is_binary(DbName), is_binary(Subtype), is_binary(Source), - is_binary(PeerId), - is_binary(UpdateSeq) + is_binary(PeerId) -> {_, Ref} = spawn_monitor(fun() -> case @@ -321,7 +320,7 @@ {ok, _} -> ok; {not_found, _} -> - update_peer_checkpoint_doc(DbName, Subtype, Source, PeerId, UpdateSeq); + update_peer_checkpoint_doc(DbName, Subtype, Source, PeerId, <<"0">>); {error, Reason} -> throw({checkpoint_commit_failure, Reason}) end
diff --git a/src/nouveau/src/nouveau_index_updater.erl b/src/nouveau/src/nouveau_index_updater.erl index 6ba3c37..1f2f5b4 100644 --- a/src/nouveau/src/nouveau_index_updater.erl +++ b/src/nouveau/src/nouveau_index_updater.erl
@@ -91,8 +91,7 @@ Index#index.dbname, <<"nouveau">>, <<(Index#index.ddoc_id)/binary, "/", (Index#index.name)/binary>>, - fabric_drop_seq:peer_id_from_sig(Index#index.dbname, Index#index.sig), - NewCurSeq + fabric_drop_seq:peer_id_from_sig(Index#index.dbname, Index#index.sig) ), Proc = get_os_process(Index#index.def_lang), try