aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2024-04-09 07:49:56 +0200
committerGitHub <noreply@github.com>2024-04-09 07:49:56 +0200
commit5c0ceec2a62e2c1003aa72b4fa78bb09e53c3a84 (patch)
tree6d6da23247e6c2578f0fbabbb130cf642c551b41
parent8aa088f7130d571ee6021d8547092162b3895b71 (diff)
downloaddendrite-5c0ceec2a62e2c1003aa72b4fa78bb09e53c3a84.tar.xz
Don't attempt to send transactions if Dendrite is shutting down (#3356)
This should avoid confusions with logs like: ``` time="2024-04-08T08:38:45.104235081Z" level=error msg="Failed to set \"scs.ems.host\" as assumed offline" func="github.com/matrix-org/dendrite/federationapi/statistics.(*ServerStatistics).Failure" file="github.com/matrix-org/dendrite/federationapi/statistics/statistics.go:204" error="sqlutil.WithTransaction.Begin: sql: database is closed" time="2024-04-08T08:38:45.104239201Z" level=error msg="Failed to set \"obermui.de\" as assumed offline" func="github.com/matrix-org/dendrite/federationapi/statistics.(*ServerStatistics).Failure" file="github.com/matrix-org/dendrite/federationapi/statistics/statistics.go:204" error="sqlutil.WithTransaction.Begin: sql: database is closed" ``` or ``` time="2024-04-08T08:38:45.105235411Z" level=error msg="Failed to get pending EDUs for \"retro76.net\"" func="github.com/matrix-org/dendrite/federationapi/queue.(*destinationQueue).getPendingFromDatabase" file="github.com/matrix-org/dendritefederationapi/queue/destinationqueue.go:258" error="sqlutil.WithTransaction.Begin: sql: database is closed" ``` [skip ci]
-rw-r--r--federationapi/queue/destinationqueue.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/federationapi/queue/destinationqueue.go b/federationapi/queue/destinationqueue.go
index f51e849f..87a6fe55 100644
--- a/federationapi/queue/destinationqueue.go
+++ b/federationapi/queue/destinationqueue.go
@@ -294,6 +294,10 @@ func (oq *destinationQueue) checkNotificationsOnClose() {
// backgroundSend is the worker goroutine for sending events.
func (oq *destinationQueue) backgroundSend() {
+ // Don't try to send transactions if we are shutting down.
+ if oq.process.Context().Err() != nil {
+ return
+ }
// Check if a worker is already running, and if it isn't, then
// mark it as started.
if !oq.running.CompareAndSwap(false, true) {