mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 07:32:57 +03:00
🐛 Bug Report: Race conditions in App Config #279
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ItalyPaleAle on GitHub.
Reproduction steps
Updating App Config using the UI could cause panics (exceptions) in Pocket ID.
The cause is that various handlers, such as
PUT /api/application-configurationcan update the config (in Go, each request is handled by a separate goroutine). Handlers like these callUpdateAppConfigwhich update the config in the DB before reloading it and populating local variables such asDbConfig.Meanwhile, other goroutines (e.g. other handlers) can access values in
DbConfig.Because there are no locks or other mechanisms to ensure safe access from multiple goroutines, this can cause race conditions.
Expected behavior
There should not be race conditions
Actual Behavior
There can be race conditions
Version and Environment
main branch
Log Output
No response
@kmendell commented on GitHub:
You say it "can" cause panics, have you reproduced this, or just something you noticed it could do? Im just curious.
@ItalyPaleAle commented on GitHub:
I have not experienced it. Race conditions can be very tough to reproduce manually since they tend to strike "at random".
A simpler way to reproduce data races like these would be to have a Go unit test created for the handlers, and then run it with
go test -race