Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions packages/common/chirp-workflow/core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ impl Worker {
loop {
tokio::select! {
_ = tick_interval.tick() => {},
res = wake_sub.next() => {
if res.is_none() {
// Cancel background tasks
gc_handle.abort();
metrics_handle.abort();

return Err(WorkflowError::SubscriptionUnsubscribed.into());
}

tick_interval.reset();
},

res = &mut gc_handle => {
tracing::error!(?res, "metrics task unexpectedly stopped");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message in this line is incorrect - it's logging "metrics task unexpectedly stopped" when handling the result from gc_handle. This should be updated to "gc task unexpectedly stopped" to accurately reflect which task failed.

Suggested change
tracing::error!(?res, "metrics task unexpectedly stopped");
tracing::error!(?res, "gc task unexpectedly stopped");

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

break;
Expand All @@ -91,18 +103,17 @@ impl Worker {
tracing::error!(?res, "metrics task unexpectedly stopped");
break;
},
res = wake_sub.next() => {
if res.is_none() {
return Err(WorkflowError::SubscriptionUnsubscribed.into());
}

tick_interval.reset();
},
_ = ctrl_c() => break,
_ = sigterm.recv() => break,
}

self.tick(&shared_client, &config, &pools, &cache).await?;
if let Err(err) = self.tick(&shared_client, &config, &pools, &cache).await {
// Cancel background tasks
gc_handle.abort();
metrics_handle.abort();

return Err(err);
}
}

self.shutdown(sigterm).await;
Expand Down Expand Up @@ -181,6 +192,7 @@ impl Worker {

tracing::info!("shutdown complete");

// This will stop all background tasks because the tokio runtime will stop
rivet_runtime::shutdown().await;
}

Expand Down
Loading