Skip to content

Correctly handle cancellation in WorkerMain#105

Merged
jadenPete merged 1 commit into
lucid-masterfrom
jpeterson-fixes-cancellation
Mar 24, 2026
Merged

Correctly handle cancellation in WorkerMain#105
jadenPete merged 1 commit into
lucid-masterfrom
jpeterson-fixes-cancellation

Conversation

@jadenPete
Copy link
Copy Markdown

Although we intended to unwrap fatal exceptions like InterruptedException in CancellableTask, we were actually throwing them outside of the underlying Future instead of failing the Future. That meant that InterruptedExceptions (and other fatal errors) floated up the call stack to the thread pool where we execute work requests, crashing the worker.

Here's a detailed breakdown of what would happen:

  1. InterruptedException is thrown inside WorkerMain#work
  2. That failure is caught inside the recover call in CancellableTask
  3. The exception is re-thrown, but because recover only catches non-fatal exceptions, the exception floats up
  4. Eventually, it reaches the top of the call stack and the worker dies

This commit fixes that issue. I've verified that Bazel acknowledges actions' being cancelled from the worker's end when these changes, and an intentional throw new InterruptedException(???) in ZincRunner, are applied.

@jadenPete jadenPete requested a review from jjudd March 23, 2026 21:40
Although we intended to unwrap fatal exceptions like
`InterruptedException` in `CancellableTask`, we were actually throwing
them outside of the underlying `Future` instead of failing the `Future`.
That meant that `InterruptedException`s (and other fatal errors) floated
up the call stack to the thread pool where we execute work requests,
crashing the worker.

Here's a detailed breakdown of what would happen:
1. `InterruptedException` is thrown inside `WorkerMain#work`
2. That failure is caught inside the `recover` call in `CancellableTask`
3. The exception is re-thrown, but because `recover` only catches
   non-fatal exceptions, the exception floats up
4. Eventually, it reaches the top of the call stack and the worker dies

This commit fixes that issue. I've verified that Bazel acknowledges
actions' being cancelled from the worker's end when these changes, and
an intentional `throw new InterruptedException(???)` in `ZincRunner`,
are applied.
@jadenPete jadenPete force-pushed the jpeterson-fixes-cancellation branch from 1bcfdf6 to 23157a3 Compare March 24, 2026 13:28
@jadenPete jadenPete merged commit cf5f2ee into lucid-master Mar 24, 2026
1 check passed
jadenPete added a commit that referenced this pull request Mar 27, 2026
Correctly handle cancellation in `WorkerMain`
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