Skip to content

Commit eeeda62

Browse files
committed
Log partition processor effective-leadership readiness and bootstrap duration
become_leader runs synchronous initialization (invoker construction, active-lock load, a legacy invocation-status scan, actuator setup, durability read) before the partition transitions to effective leadership. There was no info-level signal marking that transition or how long it took to get there -- only a coarse, scrape-interval-limited gauge and a debug-only "resumed invocations" line. Add one structured INFO log at the readiness point, with the epoch and elapsed bootstrap duration, so failover latency can be measured from logs.
1 parent 061157b commit eeeda62

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • crates/worker/src/partition/leadership

crates/worker/src/partition/leadership/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use futures::{StreamExt, TryStreamExt};
2424
use tokio::sync::mpsc;
2525
use tokio::time::Instant;
2626
use tokio_stream::wrappers::ReceiverStream;
27-
use tracing::{debug, instrument, warn};
27+
use tracing::{debug, info, instrument, warn};
2828

2929
use restate_core::network::{Oneshot, Reciprocal, TransportConnect};
3030
use restate_core::{Metadata, ShutdownError, TaskCenter, TaskKind};
@@ -458,6 +458,7 @@ where
458458
mut processor: impl Processor + HasTrimQueue + HasVQueuesMut,
459459
partition_store: &mut PartitionStore,
460460
) -> Result<(), Error> {
461+
let become_leader_started_at = tokio::time::Instant::now();
461462
let prev_mode = self.detailed_effective_mode();
462463

463464
if let State::Candidate {
@@ -715,9 +716,10 @@ where
715716
at.elapsed().friendly(),
716717
);
717718

719+
let leader_epoch = *leader_epoch;
718720
self.state = State::Leader(Box::new(LeaderState::new(
719721
processor.partition_id(),
720-
*leader_epoch,
722+
leader_epoch,
721723
processor.key_range(),
722724
shuffle_task_handle,
723725
cleaner_handle,
@@ -737,6 +739,12 @@ where
737739
node_ctx.rule_book_cache.subscribe(),
738740
)));
739741

742+
info!(
743+
leader_epoch = %leader_epoch,
744+
bootstrap_duration = ?become_leader_started_at.elapsed(),
745+
"Partition processor reached effective leadership"
746+
);
747+
740748
Ok(())
741749
} else {
742750
unreachable!("Can only become the leader if I was the candidate before!");

0 commit comments

Comments
 (0)