dbjobqueue: use background context when closing listener
This commit is contained in:
parent
6a2e719c76
commit
b03a131f13
2 changed files with 3 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,8 @@ func (q *DBJobQueue) listen(ctx context.Context, ready chan<- struct{}) {
|
||||||
panic(fmt.Errorf("error connecting to database: %v", err))
|
panic(fmt.Errorf("error connecting to database: %v", err))
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
_, err := conn.Exec(ctx, sqlUnlisten)
|
// use the empty context as the listening context is already cancelled at this point
|
||||||
|
_, err := conn.Exec(context.Background(), sqlUnlisten)
|
||||||
if err != nil && !errors.Is(err, context.DeadlineExceeded) {
|
if err != nil && !errors.Is(err, context.DeadlineExceeded) {
|
||||||
logrus.Error("Error unlistening for jobs in dequeue: ", err)
|
logrus.Error("Error unlistening for jobs in dequeue: ", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue