Skip to content

Commit 10683ca

Browse files
committed
fix: queued names quoted incorrectly in pending jobs query
1 parent 69dfcec commit 10683ca

File tree

5 files changed

+16
-37
lines changed

5 files changed

+16
-37
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: golangci/golangci-lint-action@v6
2323
with:
2424
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
25-
version: latest
25+
version: v1.64.4
2626

2727
# Optional: working directory, useful for monorepos
2828
# working-directory: somedir

.golangci.yaml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,7 @@ run:
55
issues-exit-code: 1
66
tests: true
77
# list of build tags, all linters use it. Default is empty list.
8-
build-tags: testing
9-
10-
# which dirs to skip: issues from them won't be reported;
11-
# can use regexp here: generated.*, regexp is applied on full path;
12-
# default value is empty list, but default dirs are skipped independently
13-
# from this option's value (see skip-dirs-use-default).
14-
skip-dirs: []
15-
16-
# default is true. Enables skipping of directories:
17-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
18-
skip-dirs-use-default: true
19-
20-
# which files to skip: they will be analyzed, but issues from them
21-
# won't be reported. Default value is empty list, but there is
22-
# no need to include all autogenerated files, we confidently recognize
23-
# autogenerated files. If it's not please let us know.
24-
skip-files: []
8+
build-tags: ['testing']
259

2610
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
2711
# If invoked with -mod=readonly, the go command is disallowed from the implicit
@@ -35,17 +19,12 @@ run:
3519

3620
# output configuration options
3721
output:
38-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
39-
format: colored-line-number
40-
4122
# print lines of code with issue, default is true
4223
print-issued-lines: true
4324

4425
# print linter name in the end of issue text, default is true
4526
print-linter-name: true
4627

47-
# make issues output unique by line, default is true
48-
uniq-by-line: true
4928

5029
#It's a .golangci.yml config file of this repo: we enable more linters than the default and have more strict settings:
5130

@@ -75,13 +54,7 @@ linters-settings:
7554
min-complexity: 15
7655
goimports:
7756
local-prefixes: github.com/golangci/golangci-lint
78-
gomnd:
79-
settings:
80-
mnd:
81-
# don't include the "operation" and "assign"
82-
checks: argument,case,condition,return
8357
govet:
84-
check-shadowing: true
8558
settings:
8659
printf:
8760
funcs:
@@ -181,7 +154,3 @@ issues:
181154
- funlen
182155
- cyclop
183156

184-
# golangci.com configuration
185-
# https://github.com/golangci/golangci/wiki/Configuration
186-
service:
187-
golangci-lint-version: 1.51.x # use the fixed version to not introduce new linters unexpectedly

backends/postgres/postgres_backend.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net/url"
1111
"os"
1212
"slices"
13-
"strings"
1413
"sync"
1514
"time"
1615

@@ -48,7 +47,7 @@ const (
4847
PendingJobsQuery = `SELECT id,fingerprint,queue,status,deadline,payload,retries,max_retries,run_after,ran_at,created_at,error
4948
FROM neoq_jobs
5049
WHERE status NOT IN ('processed')
51-
AND queue IN ($1)
50+
AND QUEUE = ANY($1)
5251
AND run_after <= NOW()
5352
ORDER BY created_at ASC
5453
FOR UPDATE SKIP LOCKED
@@ -1056,7 +1055,7 @@ func (p *PgBackend) getPendingJobs(ctx context.Context, conn *pgxpool.Conn) (pen
10561055
// convert watched queue map to string: "'queue1', 'queue2', ..." for use in Postgres IN statement
10571056
activeQueues := slices.Collect(maps.Keys(p.handlers))
10581057
p.mu.Unlock()
1059-
rows, err := conn.Query(ctx, PendingJobsQuery, strings.Join(activeQueues, ","))
1058+
rows, err := conn.Query(ctx, PendingJobsQuery, activeQueues)
10601059
if err != nil {
10611060
return
10621061
}

backends/postgres/postgres_backend_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ func TestHandlerRecoveryCallback(t *testing.T) {
11381138
func TestProcessPendingJobs(t *testing.T) {
11391139
connString, conn := prepareAndCleanupDB(t)
11401140
const queue = "testing"
1141+
const queue2 = "testing2"
11411142
timeoutTimer := time.After(5 * time.Second)
11421143
done := make(chan bool)
11431144
defer close(done)
@@ -1173,12 +1174,22 @@ func TestProcessPendingJobs(t *testing.T) {
11731174
return
11741175
})
11751176

1177+
h2 := handler.New(queue2, func(_ context.Context) (err error) {
1178+
return
1179+
})
1180+
11761181
// Start ensures that pending jobs will be processed
11771182
err = nq.Start(ctx, h)
11781183
if err != nil {
11791184
t.Error(err)
11801185
}
11811186

1187+
// Start listening on a second queued to make sure that pending jobs can be pulled from multiple queues
1188+
err = nq.Start(ctx, h2)
1189+
if err != nil {
1190+
t.Error(err)
1191+
}
1192+
11821193
go func() {
11831194
var err error
11841195
var status string

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
services = {
5959
postgres = {
60-
package = pkgs.postgresql;
60+
package = pkgs.postgresql_15;
6161
enable = true;
6262
listen_addresses = "127.0.0.1";
6363
port = postgresPort;

0 commit comments

Comments
 (0)