-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fix empty verification map on error #539
base: main
Are you sure you want to change the base?
Fix empty verification map on error #539
Conversation
verifiedMapStruct.VerifiedUsernameToPKID = make(map[string]*lib.PKID) | ||
|
||
// Encode the map and stick it in the database. | ||
metadataDataBuf := bytes.NewBuffer([]byte{}) |
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.
Please revert these deletions.
routes/global_state.go
Outdated
@@ -980,6 +980,8 @@ func (gs *GlobalState) Get(key []byte) (value []byte, _err error) { | |||
err := gs.GlobalStateDB.View(func(txn *badger.Txn) error { | |||
item, err := txn.Get(key) | |||
if err != nil { | |||
// Todo: I think this error needs to be processed. It could be a key not found error, then nil should be returned. |
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.
I think handling the error here means we do not need to delete the code below. Use errors.Is to compare err to badger's key not found error.
d752171
to
2118216
Compare
A few times a month, our Verified Users data disappear. I think this is because of a retrieval error from badgerdb. This fix is to make sure the Verified Users are not overwritten with an empty map.
I think error handling on txn.Get needs to be reviewed