Append a serialized audit entry to the audit WAL. `data_lsn` is the data WAL LSN this audit entry corresponds to. Returns the audit WAL's own LSN for the appended record. Uses `RecordType::Put` (0x01) — the record_type is not semantically meaningful for the audit WAL; it uses the same WAL format for compatibility with the existing reader/writer infrastructure.
(&self, audit_bytes: &[u8], data_lsn: u64)
| 56 | /// meaningful for the audit WAL; it uses the same WAL format for |
| 57 | /// compatibility with the existing reader/writer infrastructure. |
| 58 | pub fn append(&self, audit_bytes: &[u8], data_lsn: u64) -> crate::Result<u64> { |
| 59 | let mut wal = self.wal.lock().map_err(|_| crate::Error::Internal { |
| 60 | detail: "audit WAL lock poisoned".into(), |
| 61 | })?; |
| 62 | |
| 63 | // Prefix the payload with the data_lsn for cross-reference. |
| 64 | let mut payload = Vec::with_capacity(8 + audit_bytes.len()); |
| 65 | payload.extend_from_slice(&data_lsn.to_le_bytes()); |
| 66 | payload.extend_from_slice(audit_bytes); |
| 67 | |
| 68 | let lsn = wal |
| 69 | .append(RecordType::Put as u32, 0, 0, 0, &payload) |
| 70 | .map_err(crate::Error::Wal)?; |
| 71 | |
| 72 | Ok(lsn) |
| 73 | } |
| 74 | |
| 75 | /// Sync the audit WAL to disk (fsync). |
| 76 | pub fn sync(&self) -> crate::Result<()> { |