Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@blp
Copy link
Member

@blp blp commented Jan 23, 2026

CircuitThread::step() returns an error if something happens during a step (for example, if a step cannot be read or parsed in the journal), and CircuitThread::run() propagated that error to its caller with ?, but nothing reported the error to the circuit thread's error callback, and this also skipped the code at the end of CircuitThread::run() that is supposed to mark the circuit as terminated. This meant that the HTTP server still thought that the controller was continuing even though it was dead.

This commit fixes the problem by having CircuitThread::run()'s caller pass the error to the callback and calling the cleanup code.

Issue: #5504

CircuitThread::step() returns an error if something happens during a step
(for example, if a step cannot be read or parsed in the journal), and
CircuitThread::run() propagated that error to its caller with `?`, but
nothing reported the error to the circuit thread's error callback, and this
also skipped the code at the end of CircuitThread::run() that is supposed
to mark the circuit as terminated.  This meant that the HTTP server still
thought that the controller was continuing even though it was dead.

This commit fixes the problem by having CircuitThread::run()'s caller
pass the error to the callback and calling the cleanup code.

Issue: #5504

Signed-off-by: Ben Pfaff <[email protected]>
@blp blp self-assigned this Jan 23, 2026
@blp blp added bug Something isn't working ft Fault tolerant, distributed, and scale-out implementation connectors Issues related to the adapters/connectors crate rust Pull requests that update Rust code labels Jan 23, 2026
Copilot AI review requested due to automatic review settings January 23, 2026 23:44
@blp blp added the user-reported Reported by a user or customer label Jan 23, 2026
@blp blp requested a review from gz January 23, 2026 23:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts CircuitThread lifecycle handling so that errors from step() no longer short‑circuit cleanup and are reported through the controller’s error callback, ensuring the pipeline is marked terminated even when a step fails.

Changes:

  • Change CircuitThread::run to take &mut self, return from its loop via break Ok(()), and move termination/cleanup logic into a new finish(self) method.
  • Update the controller thread startup path to call run, forward any error to the controller’s error callback, and then always call finish for cleanup.
  • Generalize ControllerInner::error to accept any type convertible into Arc<ControllerError>.

Comment on lines +554 to 561
Ok(mut circuit_thread) => {
if let Err(error) = circuit_thread.run(init_status_sender) {
circuit_thread.controller.error(error, None);
}
circuit_thread.finish().inspect_err(|error| {
// Log the error before returning it from the
// thread: otherwise, only [Controller::stop]
// will join the thread and report the error.
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The error returned from circuit_thread.run is now consumed by error() and never propagated as the thread’s Result, so callers joining the thread will only see errors from finish() (if any), which differs from the prior behavior and contradicts the nearby comment about “returning it from the thread.” Consider preserving the original contract by also reflecting the run error in the returned Result (for example, by returning that error when run fails, or by combining run/finish errors in a way that ensures joiners still observe the failure).

Copilot uses AI. Check for mistakes.
@blp blp added this pull request to the merge queue Jan 24, 2026
Merged via the queue into main with commit 198ec8d Jan 24, 2026
6 of 8 checks passed
@blp blp deleted the suspend-errors branch January 24, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connectors Issues related to the adapters/connectors crate ft Fault tolerant, distributed, and scale-out implementation rust Pull requests that update Rust code user-reported Reported by a user or customer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants