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

Fix empty verification map on error #539

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

erwin-willems
Copy link
Contributor

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

@erwin-willems erwin-willems requested a review from a team as a code owner February 8, 2024 09:41
verifiedMapStruct.VerifiedUsernameToPKID = make(map[string]*lib.PKID)

// Encode the map and stick it in the database.
metadataDataBuf := bytes.NewBuffer([]byte{})
Copy link
Member

Choose a reason for hiding this comment

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

Please revert these deletions.

@@ -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.
Copy link
Member

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.

@erwin-willems erwin-willems force-pushed the fix-verification-issues branch from d752171 to 2118216 Compare April 30, 2024 06:33
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.

2 participants