none of the previous ones was it; see if it's scopeguard before trying work around Either

This commit is contained in:
Christian Schwarz
2025-02-07 01:54:37 +01:00
parent 99cc5323b6
commit a67b822c24

View File

@@ -1320,31 +1320,30 @@ impl SmgrOpFlushInProgress {
let mut fut = std::pin::pin!(fut);
let now = Instant::now();
// Whenever observe_guard gets called, or dropped,
// it adds the time elapsed since its last call to metrics.
// Last call is tracked in `now`.
let mut observe_guard = scopeguard::guard(
|| {
let elapsed = now - self.base;
// self.global_micros
// .inc_by(u64::try_from(elapsed.as_micros()).unwrap());
// self.per_timeline_micros
// .inc_by(u64::try_from(elapsed.as_micros()).unwrap());
self.base = now;
},
|mut observe| {
observe();
},
);
loop {
let v = loop {
match tokio::time::timeout(Duration::from_secs(10), &mut fut).await {
Ok(v) => return v,
Ok(v) => break v,
Err(_timeout) => {
(*observe_guard)();
let elapsed = now - self.base;
self.global_micros
.inc_by(u64::try_from(elapsed.as_micros()).unwrap());
self.per_timeline_micros
.inc_by(u64::try_from(elapsed.as_micros()).unwrap());
self.base = now;
/* bug with `now` not renewing isn't fixed */
}
}
}
};
let elapsed = now - self.base;
self.global_micros
.inc_by(u64::try_from(elapsed.as_micros()).unwrap());
self.per_timeline_micros
.inc_by(u64::try_from(elapsed.as_micros()).unwrap());
self.base = now;
v
}
}