fix(sequencer-relayer): avoid hanging while waiting for submitter task to return #1206
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
This fixes a bug whereby the relayer hangs during shutdown due to the submitter task not being instructed to shut down.
Background
Bugfix.
Changes
SequencerRelayer::new
constructs aShutdownHandle
which wraps the top-level cancellation token. This handle is held as a member variable ofSequencerRelayer
and is used to cancel all relayer child tasks if the API task exits. A clone of theShutdownHandle
is also held inmain
and is used to cancel all tasks if aSIGTERM
is received.ShutdownHandle
's token is provided to the relayer task, namedrelayer_shutdown_token
. It is never actively cancelled - only ever via the parent token.relayer_shutdown_token
is provided to the submitter task and also held as a member ofRelayer
. It is actively cancelled after the relayer's mainselect!
loop has exited if the submitter task is still running.Testing
Manual test only. I could see no way to artificially cause the relayer's
select!
loop to exit. We could potentially try dropping in some#[cfg(test)]
gated code in the loop to force this, but that would also mean we couldn't use the blackbox tests for it.Related Issues
Closes #1095.