Page 196 - 《软件学报》2021年第6期
P. 196
1770 Journal of Software 软件学报 Vol.32, No.6, June 2021
-------------------------------------------------------------------------------------
HandleRequestSyncResponse(i)==
/\\E m\in messages:
LET j==m.msource IN
/\m.mtype=RequestSyncResponse
/\m.mdest=i
/\currentTerm[i]=m.mterm
/\currentState[i]\in {Leader,LeaderCandidate}
/\syncTrack′=[syncTrack EXCEPT ![i][j]=m.msync]
/\\//\m.msyncGranted
/\m.msync<sync[i]
/\Send([mtype6UpdateSyncRequest,
mterm6currentTerm[i],
msync6Min({sync[i]} \union {k\in Nat:k>m.msync/\
Cardinality({n\in Index:log[i][n].term=k})>0}),
msource6i,
mdest6{j}])
\//\\neg m.msyncGranted
/\UNCHANGED messages
/\UNCHANGED 〈〈serverVars,log,electionVars〉〉
UpdateSync(i)==
/\currentState[i]=LeaderCandidate
/\\E Q\in Quorums:
LET syncUpdated=={m\in messages:/\m.mtype=RequestSyncResponse
/\m.mterm=currentTerm[i]
/\m.msyncGranted=TRUE
/\m.msync=sync[i]
/\m.msource\in Q
/\m.mdest=i}
IN
/\\A q\in Q:(\E m\in syncUpdated:m.msource=q)\/q=i
/\Send([mtype6UpdateSyncRequest,
mterm6currentTerm[i],
msync6currentTerm[i],
msource6i,
mdest6Q])
/\UNCHANGED 〈〈serverVars,log,syncTrack,electionVars〉〉
--------------------------------------------------------------------------------------------------------------
• HandleUpdateSyncRequest(i):i 收到 UpdateSyncRequest 请求 m,升级自己的同步号(sync′[i]=m.msync),
并将日志中的所有日志项标记为提交.然后回复确认,将升级后的同步号通知发送者.收到 i 的确认的