summaryrefslogtreecommitdiffstats
path: root/src/compaction/api.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-20 02:06:59 +0200
committertv <tv@krebsco.de>2026-10-20 02:06:59 +0200
commit5351a8b1cbdc27d4b3a5c62cb9e8a1a33115c3ae (patch)
treebcdeee903c6b1eb85325fb19b99c0e9665206871 /src/compaction/api.rs
parenta7c2b8b181059e26172288e694505287f357a881 (diff)
fix catch-up
Diffstat (limited to 'src/compaction/api.rs')
-rw-r--r--src/compaction/api.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compaction/api.rs b/src/compaction/api.rs
index 98c5351..399c3c5 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);
}