Skip to content

Commit

Permalink
Don't attempt to send transactions if Dendrite is shutting down (#3356)
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
S7evinK committed Apr 9, 2024
1 parent 8aa088f commit 5c0ceec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions federationapi/queue/destinationqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5c0ceec

Please sign in to comment.