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

Function restore_crdt_checkpoints

nodedb/src/storage/snapshot_executor.rs:231–253  ·  view source on GitHub ↗
(
    data_dir: &Path,
    _core_id: usize,
    crdt_snapshots: &[crate::data::snapshot::CrdtSnapshot],
)

Source from the content-addressed store, hash-verified

229}
230
231fn restore_crdt_checkpoints(
232 data_dir: &Path,
233 _core_id: usize,
234 crdt_snapshots: &[crate::data::snapshot::CrdtSnapshot],
235) -> crate::Result<()> {
236 if crdt_snapshots.is_empty() {
237 return Ok(());
238 }
239
240 let ckpt_dir = data_dir.join("crdt-ckpt");
241 // no-objectstore: CRDT state lands in a local engine-owned directory.
242 std::fs::create_dir_all(&ckpt_dir).map_err(crate::Error::Io)?;
243
244 for snap in crdt_snapshots {
245 let ckpt_path = ckpt_dir.join(format!("tenant-{}.ckpt", snap.tenant_id));
246 let tmp_path = ckpt_dir.join(format!("tenant-{}.ckpt.tmp", snap.tenant_id));
247 nodedb_wal::segment::atomic_write_fsync(&tmp_path, &ckpt_path, &snap.snapshot_bytes)
248 .map_err(crate::Error::Wal)?;
249 }
250
251 info!(tenants = crdt_snapshots.len(), "CRDT checkpoints restored");
252 Ok(())
253}
254
255/// Write a restore marker to the object store that tells the startup code to
256/// replay WAL records only from the given LSN forward.

Callers 1

restore_core_stateFunction · 0.85

Calls 3

atomic_write_fsyncFunction · 0.85
joinMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected