File tree Expand file tree Collapse file tree
components/spider-scheduler/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ pub trait SchedulerCore: Send {
5555 /// and writes assignments to `sink`, repeating until `cancellation_token` is fired, at which
5656 /// point it returns.
5757 ///
58+ /// The implementation does not need to fire the cancellation token when exiting on error: this
59+ /// cancellation is handled by the runtime.
60+ ///
5861 /// # Parameters
5962 ///
6063 /// * `storage_client` - The storage client used to poll the inbound queue and read state for
Original file line number Diff line number Diff line change @@ -148,12 +148,24 @@ pub async fn create_runtime<SchedulerStorageClientType: SchedulerStorageClient +
148148 let service = SchedulerServiceState :: new ( dispatch_queue_reader, registry, scheduler_id) ;
149149 let core = scheduler_config. make_core :: < SchedulerStorageClientType , DispatchQueueWriter > ( ) ;
150150
151- let core_join_handle = tokio:: spawn ( core. run (
152- storage_client,
153- dispatch_queue_writer,
154- TaskAssignmentIdIssuer :: new ( ) ,
155- cancellation_token. clone ( ) ,
156- ) ) ;
151+ let core_cancellation_token = cancellation_token. clone ( ) ;
152+ let core_join_handle = tokio:: spawn ( async move {
153+ core. run (
154+ storage_client,
155+ dispatch_queue_writer,
156+ TaskAssignmentIdIssuer :: new ( ) ,
157+ core_cancellation_token. clone ( ) ,
158+ )
159+ . await
160+ . inspect_err ( |e| {
161+ tracing:: error!(
162+ scheduler_id = % scheduler_id,
163+ error = % e,
164+ "Scheduler core exited on error. Cancelling runtime."
165+ ) ;
166+ core_cancellation_token. cancel ( ) ;
167+ } )
168+ } ) ;
157169
158170 let runtime = Runtime {
159171 core_join_handle,
You can’t perform that action at this time.
0 commit comments