Repository navigation
Conversation
Reject simple_one_for_one in both tuple and map supervisor flags with
an {unsupported_strategy, simple_one_for_one} error reason.
Document the supported worker supervision strategies and clarify that
parallel shutdown through simple_one_for_one is not available.
Add a regression test covering tuple/map flags, list/map pool options,
and pools with one or two workers.
Validation on OTP 28.5:
- All 57 tests pass; total coverage is 92%.
- Formatting, lint, hank, and xref checks pass.
- Dialyzer reports five existing test warnings.
Closes inaka#172
Contributor
Author
|
@elbrujohalcon please take a look to this PR when you will have a time. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
- Coverage 92.57% 92.03% -0.55%
==========================================
Files 10 10
Lines 458 527 +69
==========================================
+ Hits 424 485 +61
- Misses 34 42 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #172 — Asynchronous shutdown of workers.
Problem and resulting behavior
The
strategypool option accepts OTP supervisor flags, but the pool creates an individual static child specification for each worker. This initialization model does not supportsimple_one_for_one, which requires a single child template and explicit dynamic child startup.Previously, selecting this strategy did not produce a deliberate, library-specific rejection. Its behavior depended on whether OTP accepted the generated child specifications; a single-worker pool could get past that validation despite the strategy not being supported by the library.
This PR explicitly rejects
simple_one_for_onebefore starting the worker supervisor and documents the supported strategies. Pool startup now fails with the reason:{unsupported_strategy, simple_one_for_one}Maintainer direction and related discussion
This follows the maintainer's decision to exclude the strategy rather than introduce additional worker startup and shutdown behavior:
simple_one_for_one.The approach here implements that exclusion with a small runtime check, documentation, and a regression test. It does not introduce support for parallel worker shutdown or the additional lifecycle code discussed in #223.
Implementation
Explicit rejection
Two clauses added to
wpool_process_sup:start_link/3reject the strategy in either supervisor flag format:#{strategy => {simple_one_for_one, 5, 60}}#{strategy => #{strategy => simple_one_for_one}}Both return:
{error, {unsupported_strategy, simple_one_for_one}}The existing startup clause remains unchanged for other configurations. The check runs before the worker supervisor starts, so the rejected strategy does not start workers.
For a pool started with
wpool:start_sup_pool/2, OTP propagates the error through the existing supervision hierarchy:{error, {shutdown, {failed_to_start_child, WorkerSupervisorName, {unsupported_strategy, simple_one_for_one}}}}The executable production change consists of four added lines in
wpool_process_sup.erl.Documentation
The README and the
option/0andoptions/0documentation now state that the supported worker supervision strategies are:one_for_one, the default.one_for_all.rest_for_one.They explain why
simple_one_for_oneis unsupported and identify its startup error reason. The README also distinguishes the supervisor strategy configured by the pool option from the worker selection strategy passed to functions such aswpool:call.Scope and compatibility
The intentional behavior change is limited to selecting the unsupported
simple_one_for_onestrategy: it now fails explicitly and consistently, including for single-worker pools.For supported strategies, this PR preserves the existing startup implementation, application supervision tree, worker specifications, names, restart policy, and shutdown timeouts. It adds no public API or configuration options.
Regression test
One Common Test case,
unsupported_supervisor_strategy/1, covers eight combinations:For each combination, the test verifies:
unsupported_strategyreason.The single-worker cases ensure rejection is not dependent on OTP rejecting multiple child specifications for a
simple_one_for_onesupervisor.Validation
Local checks were run on OTP 28.5:
wpool_process_supcoverageDialyzer is not reported as passing: it still exits with the existing warnings concerning
cthr:pal/2, unmatched return values, and the existingcomplete_coverage/1specification/contract checks. No new warnings were reported for the added rejection clauses or regression test.OTP 29 was not tested locally and remains for CI validation.