Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent access of closed resources from async scheduled tasks
The `asyncActor` used for executing scheduled tasks must be closed before stopping the stream processor to prevent scheduled tasks from accessing resources, especially the ZeebeDb, that are closed after the stream processor stops. This is done in a somewhat convoluted way because the stream processor is not allowed to block on the closing of the asyncActor. Instead, the asyncActor receives the `closeFuture` of the stream processor and completes this when it is done closing. Unfortunately, the asyncActor is not guaranteed to run because we only start it in processing mode. That means that closing the `asyncActor` needs to check if the actor was never scheduled, or equivalently, is already closed. In that case it immediately completes the `closeFuture` of the stream processor. Luckily, scheduling an actor is atomic in the sense that the volatile lifecycle phase is set to `queued` and the task is thus no longer in phase closed. Because both scheduling and requesting the close happens within the stream processor as actor jobs, there appears to be no race condition that could leave a zombie `asyncActor`. (cherry picked from commit 9f900e3)
- Loading branch information