Skip to content

Check for an abort before each group the dispatcher fetches - #128

Merged
HalRiveria merged 4 commits into
mainfrom
fix/abort-in-group-fetch
Dec 3, 2026
Merged

HalRiveria merged 4 commits into
mainfrom
fix/abort-in-group-fetch

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Depends on #127, merge after it.

What was wrong

The dispatcher's group-fetch loop tested only the run's token, which Test-PkAbortSignal cancels after that loop, not the abort flag that Request-PkAbort and Ctrl+C raise. So an abort raised by -GroupProvider, -JobBuilder, -GroupCompleteCallback or -GroupReleaseCheck still asked -GroupProvider for more groups and built them, until -MaxQueueAhead was full, or every group when the groups had no jobs. No program started from them (#121 checks per start), but a provider that takes work off a queue lost it, and -JobBuilder ran for groups that never ran.

What changed

The fetch loop checks the abort flag before each group, as #121 did for the start loop.

How it was tested

Four new assertions in harness section O: 10 groups, -MaxQueueAhead 3, an abort from each of the four callbacks (the last two with groups that have no jobs); none may ask -GroupProvider again after the abort, or build a group asked for after it.

Before the fix (the branch's parent kit with the new harness), 5.1 and 7 alike:

  [FAIL] dispatch: a -GroupProvider that requests an abort while groups are fetched gets no more groups (asked 9 more time(s) after the abort, 9 built)
  [FAIL] dispatch: a -JobBuilder that requests an abort while groups are fetched gets no more groups (asked 2 more time(s) after the abort, 2 built)
  [FAIL] dispatch: a -GroupCompleteCallback that requests an abort while groups are fetched gets no more groups (asked 9 more time(s) after the abort, 9 built)
  [FAIL] dispatch: a -GroupReleaseCheck that requests an abort while groups are fetched gets no more groups (asked 3 more time(s) after the abort, 3 built)
4 FAILED, 24 passed

After: the full harness passes on Windows PowerShell 5.1 and PowerShell 7 (803 assertions each).

…fer only in case

A case-sensitive [hashtable]::new() job with 'canceltoken' got the kit's own token in its place, since the check used the job's own comparer and the worker's copy is case-insensitive. Two keys differing only in case collapsed into one, the later silently winning; such a job is now refused, up front for -JobParams and as it arrives for -NextJobProvider.
When -MaxOutputChars' head would end on the first half of a surrogate pair, it turned that half away but the tail kept its own size, so output exactly as long as the cap lost the pair. The tail now takes the slot the head turns away.
The group-fetch loop tested only the token, which is cancelled after it, so an abort raised by -GroupProvider, -JobBuilder, -GroupCompleteCallback or -GroupReleaseCheck still asked -GroupProvider for more groups and built them, up to -MaxQueueAhead, or every group when they had no jobs.
@HalRiveria
HalRiveria merged commit 50b7e78 into main Dec 3, 2026
3 checks passed
@HalRiveria
HalRiveria deleted the fix/abort-in-group-fetch branch December 3, 2026 16:12
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