[bugfix] Lock when checking/creating notifs to avoid race (#2890)

* [bugfix] Lock when checking/creating notifs to avoid race

* test notif spam
This commit is contained in:
tobi 2024-05-02 14:43:00 +02:00 committed by GitHub
commit ebec95a522
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 290 additions and 133 deletions

View file

@ -42,20 +42,21 @@ type State struct {
// DB provides access to the database.
DB db.DB
// FedLocks provides access to this state's
// mutex map of per URI federation locks.
// FedLocks provides access to this state's mutex
// map of per URI federation locks, intended for
// use in internal/federation functions.
//
// Used during account and status dereferencing,
// message processing in the FromFediAPI worker
// functions, and by the go-fed/activity library.
// and by the go-fed/activity library.
FedLocks mutexes.MutexMap
// AccountLocks provides access to this state's
// ProcessingLocks provides access to this state's
// mutex map of per URI locks, intended for use
// in internal/processing functions, for example
// when updating accounts, migrating, approving
// or rejecting an account, changing stats,
// pinned statuses, etc.
AccountLocks mutexes.MutexMap
// or rejecting an account, changing stats or
// pinned statuses, creating notifs, etc.
ProcessingLocks mutexes.MutexMap
// Storage provides access to the storage driver.
Storage *storage.Driver