mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-03 02:24:33 +00:00
Settle the managed run as soon as its terminal record is stored
The in-process Petri path persisted the run's terminal lifecycle
record, settled the projector, aggregated usage, and only then settled
the managed run. GET /runs/{id} reads the stored summary, so it reported
the run as ended while the delete precheck, which prefers the managed
run, still saw it running and refused the delete as active. The prune
scenario hit that window about once in thirty runs. Settle the managed
run right after the record is stored, before the view catches up.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
1483426557
commit
c264a3567c
1 changed files with 5 additions and 1 deletions
|
|
@ -498,6 +498,11 @@ pub(crate) async fn execute(state: Arc<AppState>, run_id: RunId) {
|
|||
if let Err(err) = run_records::lifecycle(&state, run_id, record).await {
|
||||
error!(run_id = %run_id, error = %err, "Failed to persist run outcome");
|
||||
}
|
||||
// The run reads as ended from the moment its terminal record is stored,
|
||||
// so the managed run settles here, before the view catches up: a delete
|
||||
// that arrives between the record and the settle otherwise refuses the
|
||||
// run as active while the API already reports it ended.
|
||||
finish(&state, run_id, status, error);
|
||||
// The view trails the terminal record; the aggregate reads the settled
|
||||
// projection, as the worker path reads the final state at worker exit.
|
||||
state.petri_projector.settle(run_id).await;
|
||||
|
|
@ -507,7 +512,6 @@ pub(crate) async fn execute(state: Arc<AppState>, run_id: RunId) {
|
|||
warn!(run_id = %run_id, error = ?err, "the run's final state could not be read for the usage aggregate");
|
||||
}
|
||||
}
|
||||
finish(&state, run_id, status, error);
|
||||
}
|
||||
|
||||
/// Bring a Petri run the server left in flight back to its worker after a
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue