Skip to content

Fix #287: terminate scheduler on abort to prevent HALT hang#303

Draft
Koan-Bot wants to merge 3 commits intoTest-More:2.0from
Koan-Bot:koan.atoomic/fix-abort-terminate
Draft

Fix #287: terminate scheduler on abort to prevent HALT hang#303
Koan-Bot wants to merge 3 commits intoTest-More:2.0from
Koan-Bot:koan.atoomic/fix-abort-terminate

Conversation

@Koan-Bot
Copy link
Contributor

What

Calling $self->terminate(1) in Scheduler::abort() so the scheduler exits after killing child jobs.

Why

When a BAIL_OUT event triggers an abort, the scheduler kills running jobs but never terminates itself — leaving yath hanging indefinitely (issue #287). Users had to ctrl+c to exit.

How

The fix is a single line: $self->terminate(1) at the end of abort(). This is the same approach as PR #289 by @troglodyne, reimplemented on current 2.0 with regression tests.

--no-abort-on-bail interaction: Safe. That flag gates job_update() (which sets halt on individual runs) — it never reaches abort(). The abort() method is only called from api_abort() (explicit abort command) and kill(), which are intentional "stop everything" actions.

Testing

  • Unit tests: Replaced the stub t/unit/Test2/Harness/Scheduler.t with 7 real subtests covering abort→terminate, kill→abort delegation, terminate idempotency, run halt marking, job PID killing, and selective run abort.
  • Integration test: t/integration/bailout.t with test fixtures (bail.tx, pass.tx) that verify yath exits on BAIL_OUT, respects --no-abort-on-bail, and passes when BAIL_OUT is not triggered.

Closes #287
Supersedes #289


🤖 Generated with Claude Code

When abort() kills child jobs, the scheduler itself was not being
terminated. This left yath hanging after a BAIL_OUT event, requiring
ctrl+c to exit. Adding $self->terminate(1) after the kill loop
ensures the scheduler exits its main loop once abort completes.

Safe with --no-abort-on-bail: that flag gates job_update() (which
never calls abort()), not the abort() method itself.

Also replaces the stub Scheduler.t with real unit tests (7 subtests)
covering abort, kill, terminate, and selective run abort behavior.
Adds integration test for BAIL_OUT termination.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@atoomic
Copy link
Collaborator

atoomic commented Feb 27, 2026

view failure from smoker while running make test

Skip blib/lib/auto/share/dist/Test2-Harness/schema/SQLite.sql (unchanged)
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..2
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate Getopt/Yath/Settings.pm in @INC (you may need to install the Getopt::Yath::Settings module) (@INC entries checked: lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2/x86_64-linux-gnu-thread-multi /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at lib/App/Yath/Script.pm line 11.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 11.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate Getopt/Yath/Settings.pm in @INC (you may need to install the Getopt::Yath::Settings module) (@INC entries checked: lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2/x86_64-linux-gnu-thread-multi /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at lib/App/Yath/Script.pm line 11.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 11.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
not ok 1 - Passed tests when run by yath (allow fork)
not ok 2 - Passed tests when run by yath (no fork)
yath exited with 512yath exited with 512make: *** [Makefile:2658: test_dynamic] Error 255

@atoomic
Copy link
Collaborator

atoomic commented Feb 27, 2026

@Koan-Bot rebase

@atoomic
Copy link
Collaborator

atoomic commented Feb 27, 2026

View the failure from smokers

PERL_DL_NONLAZY=1 "/usr/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
1..2
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate Getopt/Yath/Settings.pm in @INC (you may need to install the Getopt::Yath::Settings module) (@INC entries checked: lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2/x86_64-linux-gnu-thread-multi /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at lib/App/Yath/Script.pm line 11.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 11.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate Getopt/Yath/Settings.pm in @INC (you may need to install the Getopt::Yath::Settings module) (@INC entries checked: lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2/x86_64-linux-gnu-thread-multi /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at lib/App/Yath/Script.pm line 11.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 11.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
not ok 1 - Passed tests when run by yath (allow fork)
not ok 2 - Passed tests when run by yath (no fork)
yath exited with 512yath exited with 512make: *** [Makefile:2658: test_dynamic] Error 255

@atoomic
Copy link
Collaborator

atoomic commented Feb 27, 2026

@Koan-Bot rebase

@Koan-Bot
Copy link
Contributor Author

Rebase: Fix #287: terminate scheduler on abort to prevent HALT hang

Branch koan.atoomic/fix-abort-terminate has been rebased onto 2.0 and force-pushed.

Actions

  • Read PR comments and review feedback
  • Rebased koan.atoomic/fix-abort-terminate onto origin/2.0
  • Applied review feedback
  • Force-pushed koan.atoomic/fix-abort-terminate to origin

Automated by Kōan

@atoomic
Copy link
Collaborator

atoomic commented Feb 27, 2026

New error

1..2
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate object method "new" via package "Getopt::Yath::Option::BoolMap" (perhaps you forgot to load "Getopt::Yath::Option::BoolMap"?) at /usr/local/share/perl/5.38.2/Getopt/Yath/Option.pm line 89.
Compilation failed in require at lib/App/Yath.pm line 32.
BEGIN failed--compilation aborted at lib/App/Yath.pm line 32.
Compilation failed in require at lib/App/Yath/Script.pm line 12.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 12.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
PERL_HASH_SEED not set, setting to '20260227' for more reproducible results.
Can't locate object method "new" via package "Getopt::Yath::Option::BoolMap" (perhaps you forgot to load "Getopt::Yath::Option::BoolMap"?) at /usr/local/share/perl/5.38.2/Getopt/Yath/Option.pm line 89.
Compilation failed in require at lib/App/Yath.pm line 32.
BEGIN failed--compilation aborted at lib/App/Yath.pm line 32.
Compilation failed in require at lib/App/Yath/Script.pm line 12.
BEGIN failed--compilation aborted at lib/App/Yath/Script.pm line 12.
Compilation failed in require at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 20.
BEGIN failed--compilation aborted at /home/runner/work/Test2-Harness/Test2-Harness/scripts/yath line 22.
not ok 1 - Passed tests when run by yath (allow fork)
not ok 2 - Passed tests when run by yath (no fork)
yath exited with 65280yath exited with 65280make: *** [Makefile:2660: test_dynamic] Error 255

@Koan-Bot
Copy link
Contributor Author

Rebase: Fix #287: terminate scheduler on abort to prevent HALT hang

Branch koan.atoomic/fix-abort-terminate has been rebased onto 2.0 and force-pushed.

Actions

  • Read PR comments and review feedback
  • Rebased koan.atoomic/fix-abort-terminate onto origin/2.0
  • Applied review feedback
  • Force-pushed koan.atoomic/fix-abort-terminate to origin

Automated by Kōan

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