diff options
| author | tv <tv@krebsco.de> | 2026-10-20 02:06:59 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-20 02:06:59 +0200 |
| commit | 11a8ec06429b639e9fefec85b72a48451acad456 (patch) | |
| tree | 5dd5d9e7bd277e928a55f1651430519a5b09f57d /src/compaction/api.rs | |
| parent | 3acbbd6cd6b64c6c39408dd254cc2dbcab1b3e65 (diff) | |
fix catch-up
Diffstat (limited to 'src/compaction/api.rs')
| -rw-r--r-- | src/compaction/api.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compaction/api.rs b/src/compaction/api.rs index f5c01f2..e55d018 100644 --- a/src/compaction/api.rs +++ b/src/compaction/api.rs @@ -121,9 +121,25 @@ async fn load_report<H: Host>(host: &H, id: &str) -> Option<Report> { /// Waits until the compaction leaves `proposed`. Bounded by the proposal's own expiry, /// at which point it is reported as `expired`. async fn wait_until_final<H: Host>(host: &H, id: &str) -> Option<Report> { + // A record that was readable may be briefly unreadable or absent while concurrent + // changes merge; give up only if that persists. + const MAX_MISSES: u32 = 5; + let mut changes = host.subscribe_changes(); + let mut seen = false; + let mut misses = 0; loop { - let report = load_report(host, id).await?; + let Some(report) = load_report(host, id).await else { + misses += 1; + warn!(compaction = %id, seen, misses, "Compaction record not readable while waiting"); + if !seen || misses >= MAX_MISSES { + return None; + } + tokio::time::sleep(Duration::from_secs(1)).await; + continue; + }; + seen = true; + misses = 0; if report.phase.is_final() { return Some(report); } |
