Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete race condition #566

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/bft/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type Controller struct {
decisionChan chan decision
deliverChan chan struct{}
leaderToken chan struct{}
verificationSequence uint64
verificationSequence atomic.Uint64

controllerDone sync.WaitGroup

Expand Down Expand Up @@ -681,7 +681,7 @@ func (c *Controller) sync() (viewNum uint64, seq uint64, decisions uint64) {

c.Logger.Debugf("Node %d is setting the checkpoint after sync to view %d and seq %d", c.ID, md.ViewId, md.LatestSequence)
c.Checkpoint.Set(decision.Proposal, decision.Signatures)
c.verificationSequence = uint64(decision.Proposal.VerificationSequence)
c.verificationSequence.Store(uint64(decision.Proposal.VerificationSequence))
c.Logger.Debugf("Node %d is informing the view changer after sync of view %d and seq %d", c.ID, md.ViewId, md.LatestSequence)
c.ViewChanger.InformNewView(view)
if md.LatestSequence == 0 || newView {
Expand Down Expand Up @@ -742,12 +742,12 @@ func (c *Controller) relinquishSyncToken() {

// MaybePruneRevokedRequests prunes requests with different verification sequence
func (c *Controller) MaybePruneRevokedRequests() {
oldVerSqn := c.verificationSequence
oldVerSqn := c.verificationSequence.Load()
newVerSqn := c.Verifier.VerificationSequence()
if newVerSqn == oldVerSqn {
return
}
c.verificationSequence = newVerSqn
c.verificationSequence.Store(newVerSqn)

c.Logger.Infof("Verification sequence changed: %d --> %d", oldVerSqn, newVerSqn)
c.RequestPool.Prune(func(req []byte) error {
Expand Down Expand Up @@ -805,7 +805,7 @@ func (c *Controller) Start(startViewNumber uint64, startProposalSequence uint64,
c.Logger.Debugf("The number of nodes (N) is %d, F is %d, and the quorum size is %d", c.N, F, Q)
c.quorum = Q

c.verificationSequence = c.Verifier.VerificationSequence()
c.verificationSequence.Store(c.Verifier.VerificationSequence())

if syncOnStart {
startViewNumber, startProposalSequence, startDecisionsInView = c.syncOnStart(startViewNumber, startProposalSequence, startDecisionsInView)
Expand Down