diff options
| author | tv <tv@krebsco.de> | 2026-10-20 02:25:54 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-20 02:25:54 +0200 |
| commit | 3c61583f27dd51948382b9de53fb92cc058ca5f6 (patch) | |
| tree | 195d99f2fa3b14a1524c38e89e0487cbfc0f17e0 /src/state.rs | |
| parent | 5351a8b1cbdc27d4b3a5c62cb9e8a1a33115c3ae (diff) | |
fix catch-up / compaction in general
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/state.rs b/src/state.rs index 08ce08d..c26dbcb 100644 --- a/src/state.rs +++ b/src/state.rs @@ -531,6 +531,20 @@ impl AppState { // Sync states were reset under the document lock by the swap itself. self.publish_change(); + // Tell peers about the new epoch now instead of with the next keepalive (up to a + // keepalive interval later): sync with peers already on it resumes right away, + // and peers that never saw the commit start catching up. + let keepalive = crate::peer::local_keepalive(self).await; + for (id, _) in &peers { + if let Err(error) = self + .transport + .send_message(id, &transport::ParsedMessage::Ping(keepalive.clone())) + .await + { + debug!(peer = %id, error = %format!("{error:#}"), "Epoch announcement failed"); + } + } + for (id, _) in peers { let _ = self.sync_events.send(SyncEvent::PeerNeedsSync(id)); } @@ -584,7 +598,6 @@ impl Host for AppState { summaries.push(PeerSummary { id, active: peer.liveness == Liveness::Active, - established: peer.hello_state == HelloState::Established, epoch: peer.epoch, }); } @@ -660,8 +673,12 @@ impl Host for AppState { // Reset every peer's sync state before the lock is released, so no // message is generated from or applied to a state that describes the // old document. (Lock order doc -> peer, as in sync generation.) + let now = Instant::now(); for peer in state.peer_states.blocking_read().values() { - peer.blocking_lock().reset_sync(); + let mut peer = peer.blocking_lock(); + peer.reset_sync(); + // A fresh start, not an idle sync: no heal re-handshake for it. + peer.last_sync_rx = Some(now); } Ok(old_doc) }) |
