Skip to content

Commit 60a37bd

Browse files
committed
Stop subservices and embedded baseservice.Service on periodic jobs enqueuer start error
Just a small one where in the very rare event of a start error from the periodic jobs enqueuer, make sure to stop all subservices and stop the `baseservice.Service`. In practice this won't matter much because there's only one subservice currently that can error, but it might matter in the future in case more subservices are added.
1 parent 4313c85 commit 60a37bd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Rollbacks now use an uncancelled context so as to not leave transactions in an ambiguous state if a transaction in them fails due to context cancellation. [PR #1062](https://github.com/riverqueue/river/pull/1062).
2222
- Removing periodic jobs with IDs assigned also remove them from ID map. [PR #1070](https://github.com/riverqueue/river/pull/1070).
2323
- `river:"unique"` annotations on substructs within `JobArgs` structs are now factored into uniqueness `ByArgs` calculations. [PR #1076](https://github.com/riverqueue/river/pull/1076).
24+
- Stop subservices and embedded `baseservice.Service` on error in the event of a periodic job enqueuer start error. [PR #1081](https://github.com/riverqueue/river/pull/1081).
2425

2526
## [0.26.0] - 2025-10-07
2627

internal/maintenance/periodic_job_enqueuer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,12 @@ func (s *PeriodicJobEnqueuer) Start(ctx context.Context) error {
310310
subServices := []startstop.Service{
311311
startstop.StartStopFunc(s.periodicJobKeepAliveAndReapPeriodically),
312312
}
313+
stopServicesOnError := func() {
314+
startstop.StopAllParallel(subServices...)
315+
}
313316
if err := startstop.StartAll(ctx, subServices...); err != nil {
317+
stopServicesOnError()
318+
stopped()
314319
return err
315320
}
316321

0 commit comments

Comments
 (0)