Skip to content

job: Don't unset started when registry stops#77

Merged
joamaki merged 1 commit into
mainfrom
pr/joamaki/fix-registry-stop-race
Jun 9, 2026
Merged

job: Don't unset started when registry stops#77
joamaki merged 1 commit into
mainfrom
pr/joamaki/fix-registry-stop-race

Conversation

@joamaki

@joamaki joamaki commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

By setting 'started = false' any jobs added after the registry has stopped could get appended to the application lifecycle.

This can be hit by having a job added before starting that tries to add a job at runtime. That job is stopped after the registry and thus has time to call JobGroup.Add. It is possible to deadlock by stopping at the same time: Hive.Stop has locked the lifecycle mutex and appending is not possible and if job tries to append to the lifecycle before its stop hook gets called it'll deadlock.

There is no use-case for making the registry restartable so just remove setting started to false completely.

By setting 'started = false' any jobs added after the registry
has stopped could get appended to the application lifecycle.

This can be hit by having a job added before starting that tries
to add a job at runtime. That job is stopped after the registry and
thus has time to call JobGroup.Add. It is possible to deadlock by
stopping at the same time: Hive.Stop has locked the lifecycle mutex
and appending is not possible and if job tries to append to the lifecycle
before its stop hook gets called it'll deadlock.

There is no use-case for making the registry restartable so just remove
setting started to false completely.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
@joamaki joamaki requested a review from a team as a code owner June 9, 2026 09:47
@joamaki joamaki requested review from derailed and removed request for a team June 9, 2026 09:47

@pippolo84 pippolo84 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no use-case for making the registry restartable so just remove setting started to false completely.

Agree, changes LGTM ✔️

@joamaki joamaki merged commit c934f29 into main Jun 9, 2026
1 check passed
@joamaki joamaki deleted the pr/joamaki/fix-registry-stop-race branch June 9, 2026 09:53
@pippolo84 pippolo84 removed the request for review from derailed June 9, 2026 09:53
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