diff --git a/crates/node-core/src/events/node.rs b/crates/node-core/src/events/node.rs index 3bb4f12e2892..35d2c2b3ee91 100644 --- a/crates/node-core/src/events/node.rs +++ b/crates/node-core/src/events/node.rs @@ -87,6 +87,12 @@ impl NodeState { _ => Eta::default(), }, checkpoint, + entities_checkpoint: match &self.current_stage { + Some(current_stage) if current_stage.stage_id == stage_id => { + current_stage.entities_checkpoint + } + _ => None, + }, target, }; @@ -111,6 +117,12 @@ impl NodeState { _ => Eta::default(), }, checkpoint, + entities_checkpoint: match &self.current_stage { + Some(current_stage) if current_stage.stage_id == stage_id => { + current_stage.entities_checkpoint + } + _ => None, + }, target, }; @@ -146,11 +158,13 @@ impl NodeState { if let Some(current_stage) = self.current_stage.as_mut() { current_stage.checkpoint = checkpoint; + current_stage.entities_checkpoint = checkpoint.entities(); current_stage.eta.update(stage_id, checkpoint); let target = OptionalField(current_stage.target); - let stage_progress = - checkpoint.entities().and_then(|entities| entities.fmt_percentage()); + let stage_progress = current_stage + .entities_checkpoint + .and_then(|entities| entities.fmt_percentage()); let stage_eta = current_stage.eta.fmt_for_stage(stage_id); let message = @@ -346,6 +360,10 @@ struct CurrentStage { stage_id: StageId, eta: Eta, checkpoint: StageCheckpoint, + /// The entities checkpoint for reporting the progress. If `None`, then the progress is not + /// available, probably because the stage didn't finish running and didn't update its + /// checkpoint yet. + entities_checkpoint: Option, target: Option, } @@ -446,11 +464,11 @@ where while this.info_interval.poll_tick(cx).is_ready() { let freelist = OptionalField(this.state.freelist()); - if let Some(CurrentStage { stage_id, eta, checkpoint, target }) = + if let Some(CurrentStage { stage_id, eta, checkpoint, entities_checkpoint, target }) = &this.state.current_stage { let stage_progress = - checkpoint.entities().and_then(|entities| entities.fmt_percentage()); + entities_checkpoint.and_then(|entities| entities.fmt_percentage()); let stage_eta = eta.fmt_for_stage(*stage_id); match (stage_progress, stage_eta) {