From 536d7b7dbf3bc31adcc669e2d2daec65a2b7a746 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 17 Aug 2026 15:32:22 +0200 Subject: [PATCH] fix(notifications): retry subscriber notifications instead of dropping them on error Since e25295422 the subscriber loops in the comment, assigned, deleted and project-created listeners logged a failed Notify and moved on. On SQLite the insert regularly fails with "database is locked" (SQLITE_BUSY_SNAPSHOT: the listener's deferred transaction cannot upgrade to a write once a sibling listener has committed), so the notification was silently lost. Return the error again so the events router retries the handler with a fresh session, as it did before 2.5.0. Reported at https://community.vikunja.io/t/notification-problems-since-2-5-0/4750 --- pkg/models/listeners.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/models/listeners.go b/pkg/models/listeners.go index 12742e957..8088af5ae 100644 --- a/pkg/models/listeners.go +++ b/pkg/models/listeners.go @@ -568,8 +568,10 @@ func (s *SendTaskCommentNotification) Handle(msg *message.Message) (err error) { } err = notifications.Notify(subscriber.User, n, sess) if err != nil { - log.Errorf("Could not send task comment notification to user %d for task %d: %s", subscriber.UserID, event.Task.ID, err) - continue + // Return so the event is retried: on SQLite the insert can hit + // SQLITE_BUSY_SNAPSHOT when a sibling listener wrote first. + _ = sess.Rollback() + return err } } @@ -677,8 +679,8 @@ func (s *SendTaskAssignedNotification) Handle(msg *message.Message) (err error) } err = notifications.Notify(subscriber.User, n, sess) if err != nil { - log.Errorf("Could not send task assigned notification to user %d for task %d: %s", subscriber.UserID, event.Task.ID, err) - continue + _ = sess.Rollback() + return err } notifiedUsers[subscriber.UserID] = true @@ -725,8 +727,8 @@ func (s *SendTaskDeletedNotification) Handle(msg *message.Message) (err error) { } err = notifications.Notify(subscriber.User, n, sess) if err != nil { - log.Errorf("Could not send task deleted notification to user %d for task %d: %s", subscriber.UserID, event.Task.ID, err) - continue + _ = sess.Rollback() + return err } } @@ -1103,8 +1105,8 @@ func (s *SendProjectCreatedNotification) Handle(msg *message.Message) (err error } err = notifications.Notify(subscriber.User, n, sess) if err != nil { - log.Errorf("Could not send project created notification to user %d for project %d: %s", subscriber.UserID, event.Project.ID, err) - continue + _ = sess.Rollback() + return err } }