Skip to content

rig: record how pop exits, and reach its lifecycle paths - #204

Merged
johanix merged 1 commit into
mainfrom
johani/rig/lifecycle-checks
Aug 24, 2026
Merged

rig: record how pop exits, and reach its lifecycle paths#204
johanix merged 1 commit into
mainfrom
johani/rig/lifecycle-checks

Conversation

@johanix

@johanix johanix commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Rig capability only. Everything here passes on main as it stands; the tests that need #177 are in a separate PR stacked on it.

What was wrong

Stop() sent pop a signal and then discarded the exit status. Every test teardown goes through it, so pop's shutdown path was already one of the most heavily exercised in the suite — and a shutdown that panicked was indistinguishable from one that did not.

ExitOK() now reports whether shutdown was clean: exited on SIGINT rather than being killed after the grace period, status 0, and no panic in the output. The panic text comes with it, because that is what identifies which bug — a WaitGroup driven negative reads sync: negative WaitGroup counter.

The zombie

Reaping moves to a single waiter started at launch, and Alive() reads that rather than probing with signal 0.

This is not a hypothetical tidy-up. A process that has exited but has not been waited for is a zombie, and a zombie still accepts signal 0 — so the obvious implementation reports a corpse as alive. It did exactly that on the first run of these tests, telling me pop had survived a reload it had in fact died of.

Reaching the lifecycle from outside

Signal, APICommand and EtcFile. pop has two independent shutdown paths — a signal, and the management API's stop command — and a config reload can only be provoked by SIGHUP after changing files in the directory pop insists its config lives in.

The tests

Three, all passing today, establishing the floor: shutdown on one signal, on two in quick succession, and on a signal racing the API's stop.

Worth stating plainly, since it bears on #177: none of them fails on main. I tried to reproduce the #159 double-Done panic through every interface the rig has and could not — single SIGINT, double SIGINT, and SIGINT racing an API stop all shut down cleanly, 6/6 on the last. After the first wg.Done() the process exits before the dispatcher can dequeue a second event. These stand as regression tests, not as reproductions.

Stop() sent pop a signal and then threw away the exit status. Every test
teardown goes through it, so pop's shutdown path was already among the most
heavily exercised in the suite -- and a shutdown that panicked looked exactly
like one that did not.

Stop now records the exit, and ExitOK reports whether it was clean: exited on
SIGINT rather than being killed after the grace period, status 0, no panic in
the output. The panic text is reported too, because it is what identifies WHICH
bug -- a WaitGroup driven negative reads "sync: negative WaitGroup counter".

Reaping moves to a single waiter started at launch. That is what makes Alive()
truthful: a process that has exited but has not been waited for is a zombie,
and a zombie still accepts signal 0, so the obvious implementation would report
a corpse as alive. That is not a hypothetical -- it gave a wrong diagnosis on
the first run of these tests, reporting that pop had survived something it had
died of.

Signal, APICommand and EtcFile reach the lifecycle from outside: pop has two
independent shutdown paths (a signal and the management API's stop command),
and a config reload can only be triggered by SIGHUP after changing files in the
directory pop insists its config lives in.

The three tests here all pass as things stand. They are the floor: shutdown on
one signal, on two, and on a signal racing the API's stop.
@johanix
johanix requested a review from a team as a code owner August 24, 2026 14:13
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 10 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f1f50923-bbd7-4b10-baf3-466107900a59

📥 Commits

Reviewing files that changed from the base of the PR and between 84e51d4 and ed21f09.

📒 Files selected for processing (2)
  • rig/lifecycle_test.go
  • rig/pop.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@johanix
johanix merged commit 29d44d8 into main Aug 24, 2026
6 checks passed
@johanix
johanix deleted the johani/rig/lifecycle-checks branch August 24, 2026 14:21
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.

1 participant