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

Potential race condition in key value index #31

Open
KyleMaas opened this issue Jan 24, 2023 · 0 comments
Open

Potential race condition in key value index #31

KyleMaas opened this issue Jan 24, 2023 · 0 comments

Comments

@KyleMaas
Copy link

Probably ought to wrap this in a mutex. Index can be set, potentially multiple times if done concurrently, before the observable finished updating:

err = idx.db.Set([]byte(addr), raw)
if err != nil {
return fmt.Errorf("error in store:%w", err)
}
idx.l.Lock()
defer idx.l.Unlock()
obv, ok := idx.obvs[addr]
if ok {
err = obv.Set(v)
if err != nil {
return fmt.Errorf("error setting value in observable:%w", err)
}
}

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

No branches or pull requests

1 participant