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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Upgrade supported Go versions to 1.26 and 1.27. [PR #1356](https://github.com/riverqueue/river/pull/1356).

### Fixed

- Fixed periodic jobs advancing their durable next run time when job insertion fails. [PR #1359](https://github.com/riverqueue/river/pull/1359).

## [0.44.1] - 2026-08-21

### Fixed
Expand Down
1 change: 1 addition & 0 deletions internal/maintenance/periodic_job_enqueuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ func (s *PeriodicJobEnqueuer) insertBatch(ctx context.Context, insertParamsMany
if _, err := s.Config.Insert(ctx, tx, insertParamsMany); err != nil {
s.Logger.ErrorContext(ctx, s.Name+": Error inserting periodic jobs",
"error", err.Error(), "num_jobs", len(insertParamsMany))
return
}
}

Expand Down
32 changes: 32 additions & 0 deletions internal/maintenance/periodic_job_enqueuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,38 @@ func TestPeriodicJobEnqueuer(t *testing.T) {
require.WithinDuration(t, now.Add(2*time.Hour), svc.periodicJobs[svc.periodicJobIDs["pilot_startup_durable_2h"]].nextRunAt, time.Microsecond)
})

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

svc, bundle := setup(t)

svc.Config.Insert = func(ctx context.Context, tx riverdriver.ExecutorTx, insertParams []*rivertype.JobInsertParams) ([]*rivertype.JobInsertResult, error) {
return nil, errors.New("insert failed before database write")
}

var periodicJobUpsertManyMockCalled bool
bundle.pilotMock.PeriodicJobUpsertManyMock = func(ctx context.Context, exec riverdriver.Executor, params *riverpilot.PeriodicJobUpsertManyParams) ([]*riverpilot.PeriodicJob, error) {
periodicJobUpsertManyMockCalled = true
return nil, nil
}

now := time.Now().UTC()
svc.insertBatch(ctx, []*rivertype.JobInsertParams{{
Kind: "periodic_insert_error",
Queue: rivercommon.QueueDefault,
State: rivertype.JobStateAvailable,
}}, &riverpilot.PeriodicJobUpsertManyParams{
Jobs: []*riverpilot.PeriodicJobUpsertParams{{
ID: "periodic_insert_error",
NextRunAt: now.Add(time.Minute),
UpdatedAt: now,
}},
Schema: bundle.schema,
})

require.False(t, periodicJobUpsertManyMockCalled)
})

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

Expand Down
Loading