mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 09:52:54 +00:00
none of the previous ones was it; see if it's scopeguard before trying work around Either
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user