Skip to content

Commit

Permalink
Perform final sync once all handoff data has been sent.
Browse files Browse the repository at this point in the history
The new cluster membership code switched to forwarding
once handoff is complete.  Without this change the vnode
starts forwarding while the new owner is still processing
buffered TCP data.
  • Loading branch information
Jon Meredith committed Sep 27, 2011
1 parent 7cef0a8 commit a52b33d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/riak_core_handoff_sender.erl
Expand Up @@ -70,6 +70,16 @@ start_fold(TargetNode, Module, Partition, ParentPid, SslOpts) ->
foldfun=fun visit_item/3,
acc0={Socket,ParentPid,Module,TcpMod,0,0,ok}},
VMaster, infinity),
%% One last sync to make sure the message has been received.
%% post-0.14 vnodes switch to handoff to forwarding immediately
%% so handoff_complete can only be sent once all of the data is
%% written. handle_handoff_data is a sync call, so once
%% we receive the sync the remote side will be up to date.
lager:debug("~p ~p Sending final sync", [Partition, Module]),
ok = TcpMod:send(Socket, <<?PT_MSG_SYNC:8>>),
{ok,[?PT_MSG_SYNC|<<"sync">>]} = TcpMod:recv(Socket, 0),
lager:debug("~p ~p Final sync received", [Partition, Module]),

EndFoldTime = now(),
FoldTimeDiff = timer:now_diff(EndFoldTime, StartFoldTime) / 1000000,
case ErrStatus of
Expand Down

0 comments on commit a52b33d

Please sign in to comment.