One iteration: snapshot the near-expiry lease set under a short read lock, then re-acquire each one. Errors are logged at warn — the next tick retries automatically. Why we use wall-clock nanoseconds, not `hlc_clock.peek()`**: `peek` returns the last HLC the clock observed, which may be frozen at the moment the lease was stamped if nothing else has advanced the clock since. We want "real time now
(&self)
| 170 | /// and avoids spuriously classifying leases as "not near |
| 171 | /// expiry" just because the HLC hasn't ticked. |
| 172 | fn tick(&self) { |
| 173 | let Some(shared) = self.shared.upgrade() else { |
| 174 | return; |
| 175 | }; |
| 176 | let now_wall_ns = super::wall_now_ns(); |
| 177 | let near_expiry = collect_near_expiry(&shared, now_wall_ns, &self.config); |
| 178 | if near_expiry.is_empty() { |
| 179 | return; |
| 180 | } |
| 181 | debug!( |
| 182 | count = near_expiry.len(), |
| 183 | "descriptor lease renewal: re-acquiring near-expiry leases" |
| 184 | ); |
| 185 | for (id, held_version) in near_expiry { |
| 186 | let current_version = lookup_current_version(&shared, &id); |
| 187 | match current_version { |
| 188 | Some(v) => { |
| 189 | let version = v.max(held_version); |
| 190 | if let Err(e) = super::propose::force_refresh_lease( |
| 191 | &shared, |
| 192 | id.clone(), |
| 193 | version, |
| 194 | self.config.full_duration, |
| 195 | ) { |
| 196 | warn!( |
| 197 | descriptor = ?id, |
| 198 | version, |
| 199 | error = %e, |
| 200 | "descriptor lease renewal: re-acquire failed" |
| 201 | ); |
| 202 | self.loop_metrics.record_error("renew"); |
| 203 | } |
| 204 | } |
| 205 | None => { |
| 206 | if let Err(e) = super::release::release_leases(&shared, vec![id.clone()]) { |
| 207 | warn!( |
| 208 | descriptor = ?id, |
| 209 | error = %e, |
| 210 | "descriptor lease renewal: release after drop failed" |
| 211 | ); |
| 212 | self.loop_metrics.record_error("release"); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | /// Look up the current persisted version for a descriptor. |
no test coverage detected