Skip to content

Commit

Permalink
Witnesses should only receive committed entries.
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: fnabulsi

Differential Revision: D70017788

fbshipit-source-id: 9b2203dc44ee6f1f134f5c6ad7104c8e57201aea
  • Loading branch information
Jose-Angel Herrero Bajo authored and facebook-github-bot committed Feb 22, 2025
1 parent 00f6b13 commit defdaec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wa_raft_log_catchup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ send_logs_impl(#raft_identity{node = PeerNode} = Peer, NextLogIndex, LeaderTerm,
{ok, E} = wa_raft_log:get(Log, NextLogIndex, LogBatchEntries, LogBatchBytes),
E;
true ->
{ok, T} = wa_raft_log:get_terms(Log, NextLogIndex, LogBatchEntries),
{ok, T} = wa_raft_log:get_terms(Log, NextLogIndex, min(LogBatchEntries, max(0, LeaderCommitIndex - NextLogIndex + 1))),
[{Term, []} || Term <- T]
end,

Expand Down
2 changes: 1 addition & 1 deletion src/wa_raft_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,7 @@ heartbeat(?IDENTITY_REQUIRES_MIGRATION(_, FollowerId) = Sender,
Entries =
case lists:member({Name, FollowerId}, Witnesses) of
true ->
MaxWitnessLogEntries = ?RAFT_HEARTBEAT_MAX_ENTRIES_TO_WITNESS(App),
MaxWitnessLogEntries = min(?RAFT_HEARTBEAT_MAX_ENTRIES_TO_WITNESS(App), max(0, CommitIndex - FollowerNextIndex + 1)),
{ok, Terms} = wa_raft_log:get_terms(View, FollowerNextIndex, MaxWitnessLogEntries),
[{Term, []} || Term <- Terms];
_ ->
Expand Down

0 comments on commit defdaec

Please sign in to comment.