Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed periodic jobs advancing their durable next run time when job insertion fails. [PR #1359](https://github.com/riverqueue/river/pull/1359).
- Improved SQLite queue count performance on large job tables by limiting counts to available and running jobs so the existing state and queue index can be used. [PR #1360](https://github.com/riverqueue/river/pull/1360).

## [0.44.1] - 2026-08-21

Expand Down
28 changes: 28 additions & 0 deletions riverdriver/riverdrivertest/job_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ func exerciseJobRead[TTx any](ctx context.Context, t *testing.T, executorWithTx
require.Equal(t, int64(1), countsByQueue[1].CountRunning)
})

t.Run("IgnoresJobsInOtherStates", func(t *testing.T) {
t.Parallel()

exec, _ := setup(ctx, t)

for _, state := range []rivertype.JobState{
rivertype.JobStateCancelled,
rivertype.JobStateCompleted,
rivertype.JobStateDiscarded,
rivertype.JobStatePending,
rivertype.JobStateRetryable,
rivertype.JobStateScheduled,
} {
_ = testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Queue: new("queue1"), State: new(state)})
}

countsByQueue, err := exec.JobCountByQueueAndState(ctx, &riverdriver.JobCountByQueueAndStateParams{
QueueNames: []string{"queue1"},
Schema: "",
})
require.NoError(t, err)

require.Len(t, countsByQueue, 1)
require.Equal(t, "queue1", countsByQueue[0].Queue)
require.Equal(t, int64(0), countsByQueue[0].CountAvailable)
require.Equal(t, int64(0), countsByQueue[0].CountRunning)
})

t.Run("IncludesRequestedQueuesThatHaveNoJobs", func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 1 addition & 0 deletions riverdriver/riversqlite/internal/dbsqlc/river_job.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ WITH queue_stats AS (
COUNT(CASE WHEN river_job.state = 'running' THEN 1 END) AS count_running
FROM /* TEMPLATE: schema */river_job
WHERE river_job.queue IN (sqlc.slice('queue_names'))
AND river_job.state IN ('available', 'running')
GROUP BY river_job.queue
)

Expand Down
1 change: 1 addition & 0 deletions riverdriver/riversqlite/internal/dbsqlc/river_job.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading