Skip to content

Commit

Permalink
refactor: delay initial sync trigger
Browse files Browse the repository at this point in the history
Don't immediately dispatch a consistency probe when the router starts
up, when it may be under higher initial load.
  • Loading branch information
domodwyer committed Sep 26, 2023
1 parent 3947886 commit 669fe66
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions router/src/gossip/anti_entropy/sync/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ where
// Wait at least SYNC_ROUND_INTERVAL between consistency checks.
ticker.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);

let _ = ticker.tick().await;

loop {
tokio::select! {
_ = ticker.tick() =>
Expand Down Expand Up @@ -313,15 +315,17 @@ mod tests {

// Wait for a probe to happen.
let mut calls = async {
loop {
for _ in 0..100 {
tokio::time::pause();
let calls = consistency_prober.calls();
if !calls.is_empty() {
return calls;
}
tokio::time::resume();
tokio::time::sleep(Duration::from_millis(50)).await;
}
panic!("timeout");
}
.with_timeout_panic(Duration::from_secs(5))
.await;

// It's technically possible that multiple probes could have been sent
Expand Down

0 comments on commit 669fe66

Please sign in to comment.