🐛 Bug Report: Race conditions in App Config #279

Closed
opened 2025-10-09 16:36:52 +03:00 by OVERLORD · 2 comments
Owner

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-configuration can update the config (in Go, each request is handled by a separate goroutine). Handlers like these call UpdateAppConfig which update the config in the DB before reloading it and populating local variables such as DbConfig.

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

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-configuration` can update the config (in Go, each request is handled by a separate goroutine). Handlers like these call `UpdateAppConfig` which update the config in the DB before reloading it and populating local variables such as `DbConfig`. 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_
OVERLORD added the bug label 2025-10-09 16:36:52 +03:00
Author
Owner

@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.

@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.
Author
Owner

@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

@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`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-2#279