summaryrefslogtreecommitdiffstats
path: root/src/compaction/api.rs
diff options
context:
space:
mode:
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 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);
}