Route authorization query to read-only database replica to reduce primary database load

This commit is contained in:
binwiederhier
2026-03-15 22:01:19 -04:00
parent f5c255c53c
commit 6b38acb23a
2 changed files with 6 additions and 2 deletions

View File

@@ -1787,4 +1787,8 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
## Not released yet
Nothing to see here.
### ntfy server v2.20.x (UNRELEASED)
**Bug fixes + maintenance:**
* Route authorization query to read-only database replica to reduce primary database load

View File

@@ -642,7 +642,7 @@ func (a *Manager) AllowReservation(username string, topic string) error {
// - Furthermore, the query prioritizes more specific permissions (longer!) over more generic ones, e.g. "test*" > "*"
// - It also prioritizes write permissions over read permissions
func (a *Manager) authorizeTopicAccess(usernameOrEveryone, topic string) (read, write, found bool, err error) {
rows, err := a.db.Query(a.queries.selectTopicPerms, Everyone, usernameOrEveryone, topic)
rows, err := a.db.ReadOnly().Query(a.queries.selectTopicPerms, Everyone, usernameOrEveryone, topic)
if err != nil {
return false, false, false, err
}