Skip to content

Commit 3003a5f

Browse files
committed
fixup! Use dotted version vectors for causality tracking when running tests
1 parent f5de4a1 commit 3003a5f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/plumtree_broadcast.erl

+8-2
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ handle_broadcast(false, _MessageId, _Message, Mod, _Round, Root, From, State) ->
380380
State1 = add_lazy(From, Root, State),
381381
_ = send({prune, Root, myself()}, Mod, From),
382382
State1;
383+
%% The next clause is designed to allow the callback to override the message id
384+
%% after the merge, suppose node A eager pushed a change to node B, node B would then lazy
385+
%% push it to node C, at this point the message id being sent to C is the one that originated
386+
%% from A. Concurrently B takes an update that subsumes the previous one, now node C receives the
387+
%% lazy push and hasn't seen this message and asks B to graft it, if C now sends the message id
388+
%% that it got from A, node B will not answer the graft since it is deemed stale.
389+
%% With this extra clause the callback is able to return a new message id that resulted from
390+
%% the merge and have that be propagated.
383391
handle_broadcast({true, MessageId}, _OldMessageId, Message, Mod, Round, Root, From, State) ->
384392
handle_broadcast(true, MessageId, Message, Mod, Round, Root, From, State);
385393
handle_broadcast(true, MessageId, Message, Mod, Round, Root, From, State) -> %% valid msg
@@ -467,8 +475,6 @@ send_lazy(Peer, Messages) ->
467475
{MessageId, Mod, Round, Root} <- ordsets:to_list(Messages)].
468476

469477
send_lazy(MessageId, Mod, Round, Root, Peer) ->
470-
% plumtree_util:log(debug, "sending lazy push ~p",
471-
% [{i_have, MessageId, Mod, Round, Root, myself()}]),
472478
send({i_have, MessageId, Mod, Round, Root, myself()}, Mod, Peer).
473479

474480
maybe_exchange(State) ->

0 commit comments

Comments
 (0)