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

Add syncMu to AlgorandFullNode OnNewBlock #1623

Merged

Conversation

ghost
Copy link

@ghost ghost commented Oct 14, 2020

Summary

Adding a new mutex to AlgorandFullNode so that OnNewBlock wouldn't be blocked by oldKeyDeletionThread during catchup.

Test Plan

Copy link
Contributor

@tsachiherman tsachiherman left a 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()
Copy link
Contributor

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
Comment on lines 118 to 122
// 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
Copy link
Contributor

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
Copy link
Contributor

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 ?

Copy link
Contributor

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'

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. thanks!

@tsachiherman tsachiherman merged commit ebc90af into algorand:master Oct 14, 2020
tsachiherman pushed a commit to tsachiherman/go-algorand that referenced this pull request Jul 7, 2021
separate synchronization primitive for updating the latest round reached timestamp to improve catchup performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants