-
Notifications
You must be signed in to change notification settings - Fork 198
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
No snapshot after start in epoch #3623
Conversation
Codecov Report
@@ Coverage Diff @@
## development #3623 +/- ##
===============================================
- Coverage 73.69% 73.67% -0.02%
===============================================
Files 585 585
Lines 75317 75335 +18
===============================================
+ Hits 55503 55506 +3
- Misses 15405 15418 +13
- Partials 4409 4411 +2
Continue to review full report at Codecov.
|
trie/trieStorageManager.go
Outdated
|
||
log.Debug("snapshotTrieStorageManager get", | ||
"err", err.Error(), | ||
"value", val, |
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.
isn't the value nil
? also, the code might panic because you don't check if the error is different than nil
, so err.Error()
would panic if err
is nil
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.
Refactored
trie/trieStorageManager.go
Outdated
func (tsm *trieStorageManager) EpochConfirmed(epoch uint32, _ uint64) { | ||
tsm.flagDisableOldStorage.Toggle(epoch >= tsm.disableOldStorageEpoch) | ||
log.Debug("old trie storage", "disabled", tsm.flagDisableOldStorage.IsSet()) | ||
|
||
err := tsm.mainStorer.Put([]byte(activeDBKey), []byte(activeDBVal)) | ||
log.LogIfError(err, "error", "set db as activeDB error") |
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.
better use
if err != nil {
log.Error("error while putting active DB value into main storer", "error", err)
}
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.
Done.
trie/trieStorageManager.go
Outdated
func (tsm *trieStorageManager) EpochConfirmed(epoch uint32, _ uint64) { | ||
tsm.flagDisableOldStorage.Toggle(epoch >= tsm.disableOldStorageEpoch) | ||
log.Debug("old trie storage", "disabled", tsm.flagDisableOldStorage.IsSet()) | ||
|
||
err := tsm.mainStorer.Put([]byte(activeDBKey), []byte(activeDBVal)) |
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 looks like this is the only place when you set the value for active DB. I guess it is meant to be set only on the first confirmed epoch, right? So if starting from genesis, epoch 0 -> epoch 1 will trigger the value to be set; or when starting in epoch, only the next epoch?
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.
This func is called every time when an epoch is changed, or when the trieStorageManager is initialized, so activeDBKey
will be saved in each storer (each epoch a new storer is created)
trie/trieStorageManager.go
Outdated
@@ -493,6 +502,19 @@ func (tsm *trieStorageManager) takeCheckpoint(checkpointEntry *snapshotsQueueEnt | |||
} | |||
} | |||
|
|||
func isActiveDb(stsm *snapshotTrieStorageManager) bool { | |||
val, err := stsm.Get([]byte(activeDBKey)) |
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.
Check the err for nil?
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.
Done.
cb6179b
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.
In this PR: Add a specific key-value to each trie storer. When snapshoting, check if that value is present in the last storage, and only then start the snapshot. This way, after start in epoch no snapshot is triggered.