Skip to content

Commit

Permalink
dbjobqueue: use background context when closing listener
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap authored and ondrejbudai committed Sep 2, 2022
1 parent 6a2e719 commit b03a131
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/osbuild-composer-dbjobqueue-tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package main
Expand Down
3 changes: 2 additions & 1 deletion pkg/jobqueue/dbjobqueue/dbjobqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b03a131

Please sign in to comment.