dbjobqueue: use background context when closing listener

This commit is contained in:
Lukas Zapletal 2022-06-03 17:01:38 +02:00 committed by Ondřej Budai
parent 6a2e719c76
commit b03a131f13
2 changed files with 3 additions and 1 deletions

View file

@ -1,3 +1,4 @@
//go:build integration
// +build integration
package main

View file

@ -182,7 +182,8 @@ func (q *DBJobQueue) listen(ctx context.Context, ready chan<- struct{}) {
panic(fmt.Errorf("error connecting to database: %v", err))
}
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) {
logrus.Error("Error unlistening for jobs in dequeue: ", err)
}