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
Add syncMu to AlgorandFullNode OnNewBlock #1623
Add syncMu to AlgorandFullNode OnNewBlock #1623
Conversation
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.
Few small requests, but otherwise looks good.
node/node.go
Outdated
@@ -578,7 +581,9 @@ func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid) (res | |||
// Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound | |||
func (node *AlgorandFullNode) Status() (s StatusReport, err error) { | |||
node.mu.Lock() |
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.
It would be sufficient to take the new lock during the setup of these two output variables, i.e.
node.syncMu.Lock()
s.LastRoundTimestamp = node.lastRoundTimestamp
s.HasSyncedSinceStartup = node.hasSyncedSinceStartup
node.mu.Unlock()
node.mu.Lock()
defer node.syncMu.Unlock()
...
node/node.go
Outdated
// use syncMu for locking lastRoundTimestamp and hasSyncedSinceStartup | ||
// syncMu added so OnNewBlock wouldn't be blocked by oldKeyDeletionThread during catchup | ||
syncMu deadlock.Mutex | ||
lastRoundTimestamp time.Time | ||
hasSyncedSinceStartup bool |
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.
When writing a variable description in go, try to always start with the variable name; go-vet would complain about that for public functions.
node/node.go
Outdated
@@ -115,6 +115,9 @@ type AlgorandFullNode struct { | |||
|
|||
log logging.Logger | |||
|
|||
// use syncMu for locking lastRoundTimestamp and hasSyncedSinceStartup | |||
// syncMu added so OnNewBlock wouldn't be blocked by oldKeyDeletionThread during catchup | |||
syncMu deadlock.Mutex |
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.
could you change the variable name to something more concrete. ( since all mutexes are meant for syncing.. )
maybe lastRoundTimeMu ?
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.
the two variables together might be 'sync status', so this could be the 'sync status mutex'
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.
looks good. thanks!
separate synchronization primitive for updating the latest round reached timestamp to improve catchup performance.
Summary
Adding a new mutex to AlgorandFullNode so that OnNewBlock wouldn't be blocked by oldKeyDeletionThread during catchup.
Test Plan