Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit 5c0ceec

Browse files
authored
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]
1 parent 8aa088f commit 5c0ceec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

federationapi/queue/destinationqueue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ func (oq *destinationQueue) checkNotificationsOnClose() {
294294

295295
// backgroundSend is the worker goroutine for sending events.
296296
func (oq *destinationQueue) backgroundSend() {
297+
// Don't try to send transactions if we are shutting down.
298+
if oq.process.Context().Err() != nil {
299+
return
300+
}
297301
// Check if a worker is already running, and if it isn't, then
298302
// mark it as started.
299303
if !oq.running.CompareAndSwap(false, true) {

0 commit comments

Comments
 (0)