Execute a coordinated checkpoint: flush all engine state to disk and return this core's checkpoint LSN. 1. Checkpoint vector indexes (HNSW segments → disk files). 2. Export CRDT snapshots (Loro docs → disk files). 3. redb sparse engine is already ACID — no action needed. 4. CSR is rebuilt from redb edge store on startup — no action needed. 5. Return the core's watermark LSN as the checkpoint poin
(
&mut self,
task: &ExecutionTask,
)
| 242 | /// 4. CSR is rebuilt from redb edge store on startup — no action needed. |
| 243 | /// 5. Return the core's watermark LSN as the checkpoint point. |
| 244 | pub(in crate::data::executor) fn execute_checkpoint( |
| 245 | &mut self, |
| 246 | task: &ExecutionTask, |
| 247 | ) -> Response { |
| 248 | let checkpoint_lsn = self.watermark.as_u64(); |
| 249 | |
| 250 | // 1. Flush vector indexes to disk. |
| 251 | let vectors_checkpointed = self.checkpoint_vector_indexes(); |
| 252 | |
| 253 | // 2. Flush CRDT snapshots to disk. |
| 254 | let crdts_checkpointed = self.checkpoint_crdt_engines(); |
| 255 | |
| 256 | // 3. Flush spatial R-tree indexes to disk. |
| 257 | let spatial_checkpointed = self.checkpoint_spatial_indexes(); |
| 258 | |
| 259 | // 4. Compact CSR write buffers into dense arrays for clean state. |
| 260 | if let Err(e) = self.csr.compact_all() { |
| 261 | tracing::warn!(error = %e, "CSR compaction rejected by memory governor during snapshot; skipping"); |
| 262 | } |
| 263 | |
| 264 | // 5. Record completed flushes in the checkpoint coordinator |
| 265 | // and advance the checkpoint LSN for WAL truncation safety. |
| 266 | self.checkpoint_coordinator |
| 267 | .record_flush("vector", vectors_checkpointed); |
| 268 | self.checkpoint_coordinator |
| 269 | .record_flush("crdt", crdts_checkpointed); |
| 270 | self.checkpoint_coordinator |
| 271 | .record_flush("spatial", spatial_checkpointed); |
| 272 | self.checkpoint_coordinator |
| 273 | .complete_checkpoint(checkpoint_lsn); |
| 274 | |
| 275 | info!( |
| 276 | core = self.core_id, |
| 277 | checkpoint_lsn, |
| 278 | vectors_checkpointed, |
| 279 | crdts_checkpointed, |
| 280 | spatial_checkpointed, |
| 281 | dirty_pages = self.checkpoint_coordinator.total_dirty_pages(), |
| 282 | "core checkpoint complete" |
| 283 | ); |
| 284 | |
| 285 | // Return the checkpoint LSN as the response payload. |
| 286 | let payload = checkpoint_lsn.to_le_bytes().to_vec(); |
| 287 | self.response_with_payload(task, payload) |
| 288 | } |
| 289 | |
| 290 | /// Checkpoint all CRDT tenant engines to disk. |
| 291 | /// |
no test coverage detected