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

Method append_durable

nodedb/src/wal/audit_segment.rs:84–99  ·  view source on GitHub ↗

Append AND sync atomically. This is the primary durable write path.

(&self, audit_bytes: &[u8], data_lsn: u64)

Source from the content-addressed store, hash-verified

82
83 /// Append AND sync atomically. This is the primary durable write path.
84 pub fn append_durable(&self, audit_bytes: &[u8], data_lsn: u64) -> crate::Result<u64> {
85 let mut wal = self.wal.lock().map_err(|_| crate::Error::Internal {
86 detail: "audit WAL lock poisoned".into(),
87 })?;
88
89 let mut payload = Vec::with_capacity(8 + audit_bytes.len());
90 payload.extend_from_slice(&data_lsn.to_le_bytes());
91 payload.extend_from_slice(audit_bytes);
92
93 let lsn = wal
94 .append(RecordType::Put as u32, 0, 0, 0, &payload)
95 .map_err(crate::Error::Wal)?;
96 wal.sync().map_err(crate::Error::Wal)?;
97
98 Ok(lsn)
99 }
100
101 /// Replay all audit WAL entries for crash recovery.
102 ///

Callers 2

append_and_recoverFunction · 0.80
append_audit_durableMethod · 0.80

Calls 4

lockMethod · 0.80
lenMethod · 0.45
appendMethod · 0.45
syncMethod · 0.45

Tested by 1

append_and_recoverFunction · 0.64