-
Notifications
You must be signed in to change notification settings - Fork 295
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
Fixed data race. #4559
Fixed data race. #4559
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -575,19 +575,19 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error { | |
if _, err := consensus.Blockchain().InsertChain([]*types.Block{blk}, !consensus.FBFTLog().IsBlockVerified(blk.Hash())); err != nil { | ||
switch { | ||
case errors.Is(err, core.ErrKnownBlock): | ||
consensus.getLogger().Info().Msg("[preCommitAndPropose] Block already known") | ||
consensus.GetLogger().Info().Msg("[preCommitAndPropose] Block already known") | ||
default: | ||
consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain") | ||
consensus.GetLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain") | ||
return | ||
} | ||
} | ||
|
||
consensus.mutex.Lock() | ||
consensus.getLogger().Info().Msg("[preCommitAndPropose] Start consensus timer") | ||
consensus.consensusTimeout[timeoutConsensus].Start() | ||
|
||
// Send signal to Node to propose the new block for consensus | ||
consensus.getLogger().Info().Msg("[preCommitAndPropose] sending block proposal signal") | ||
|
||
consensus.mutex.Unlock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we release lock exactly here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to excludes line |
||
consensus.ReadySignal(AsyncProposal) | ||
}() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetLogger() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we obtained lock above on line 584
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetLogger() has lock inside, so it will be deadlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetLogger is a public function, it should be improved to not have such a constraints. We can't make a function public and ask users to not use it in a certain conditions, right?