MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_restore_marker

Function read_restore_marker

nodedb/src/storage/snapshot_executor.rs:280–297  ·  view source on GitHub ↗

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>)

Source from the content-addressed store, hash-verified

278/// Called during startup. Returns the LSN to replay from, or `None` if
279/// no restore marker exists (normal startup).
280pub 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)]
300mod tests {

Callers

nothing calls this directly

Calls 4

okMethod · 0.45
getMethod · 0.45
bytesMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected