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 | bb2742d13c827c2cf0a233396d14640041f62986 (patch) | |
| tree | 24210fba28579c265d88c134226a311d4d640e82 /src/compaction/api.rs | |
| parent | 01f1d19d6b0b456991017022547e8c86bc8305ae (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 de035a2..073ed6e 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); } |
