Read and consume the restore marker (if present). Called during startup. Returns the LSN to replay from, or `None` if no restore marker exists (normal startup).
(store: &Arc<dyn ObjectStore>)
| 278 | /// Called during startup. Returns the LSN to replay from, or `None` if |
| 279 | /// no restore marker exists (normal startup). |
| 280 | pub async fn read_restore_marker(store: &Arc<dyn ObjectStore>) -> Option<u64> { |
| 281 | let marker_key = ObjectPath::from("restore_from_lsn"); |
| 282 | let result = store.get(&marker_key).await.ok()?; |
| 283 | let bytes = result.bytes().await.ok()?; |
| 284 | let content = std::str::from_utf8(&bytes).ok()?; |
| 285 | let lsn = content.trim().parse::<u64>().ok()?; |
| 286 | |
| 287 | // Delete the marker after reading — it's a one-time signal. |
| 288 | if let Err(e) = store.delete(&marker_key).await { |
| 289 | warn!(error = %e, "failed to delete restore marker"); |
| 290 | } |
| 291 | |
| 292 | info!( |
| 293 | restore_from_lsn = lsn, |
| 294 | "restore marker found — WAL replay will start from this LSN" |
| 295 | ); |
| 296 | Some(lsn) |
| 297 | } |
| 298 | |
| 299 | #[cfg(test)] |
| 300 | mod tests { |