Skip to content

Startstop: Start successfully again even in the event of a partial start#1187

Merged
brandur merged 1 commit intomasterfrom
brandur-start-successfully-even-on-partial-start
Mar 26, 2026
Merged

Startstop: Start successfully again even in the event of a partial start#1187
brandur merged 1 commit intomasterfrom
brandur-start-successfully-even-on-partial-start

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Mar 26, 2026

This one's presented as an alternative to #1136. Basically, a current
problem with the start/stop infrastructure is that in the event of a
partial start where a service returns from its start function, but
without Stop having been called on, we can get into a situation where
the start/stop's isRunning flag is still set to true, and when the
start/stop is started again, it'll fall through thinking it's already
running.

Here, we check for this condition on subsequent starts. If the stopped
channel is non-nil but already closed, we reset all internal state
including isRunning so the service can start again.

To prove this works, I pull in the test case added in #1136 verbatim,
and also add one more specific test in start_stop_test.go for a more
precise version.

@brandur brandur force-pushed the brandur-start-successfully-even-on-partial-start branch from d9bb962 to 63f1cda Compare March 26, 2026 05:56
This one's presented as an alternative to #1136. Basically, a current
problem with the start/stop infrastructure is that in the event of a
partial start where a service returns from its start function, but
without `Stop` having been called on, we can get into a situation where
the start/stop's `isRunning` flag is still set to true, and when the
start/stop is started again, it'll fall through thinking it's already
running.

Here, we check for this condition on subsequent starts. If the `stopped`
channel is non-nil but already closed, we reset all internal state
including `isRunning` so the service can start again.

To prove this works, I pull in the test case added in #1136 verbatim,
and also add one more specific test in `start_stop_test.go` for a more
precise version.
@brandur brandur force-pushed the brandur-start-successfully-even-on-partial-start branch from 63f1cda to a6b9abe Compare March 26, 2026 06:02
@brandur brandur requested a review from bgentry March 26, 2026 06:05
@brandur
Copy link
Contributor Author

brandur commented Mar 26, 2026

Thanks!

@brandur brandur merged commit 7993e94 into master Mar 26, 2026
15 checks passed
@brandur brandur deleted the brandur-start-successfully-even-on-partial-start branch March 26, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants