Skip to main content

ferrum_interfaces/vnext/completion/checkpoint_access/
recovery.rs

1use super::*;
2use crate::vnext::{CompletionSweepEntry, CompletionSweepObservation, CompletionSweepReceipt};
3
4impl<R: DeviceRuntime> CompletionReaper<R> {
5    /// Runs a bounded sweep and blocking recovery for native checkpoint results
6    /// abandoned by their public access handles. Call from the existing device
7    /// completion worker, not a request/admission thread. Live consumers are
8    /// never drained or discarded by this operation.
9    ///
10    /// Failed drains remain in the same reaper's quarantine for a later retry.
11    /// Successful cleanup discards results; it cannot install a restore frontier
12    /// or turn drain evidence into a successful capture.
13    pub fn recover_abandoned_checkpoints(
14        &self,
15        maximum_slots: usize,
16    ) -> Result<CompletionSweepReceipt, VNextError> {
17        let mut receipt = self.poll_bounded(maximum_slots)?;
18        for entry in &mut receipt.state_transfers {
19            match self.recover_abandoned_state_transfer_slot(entry.slot_id) {
20                Ok(Some(observation)) => entry.observation = observation,
21                Ok(None) => {}
22                Err(error) => receipt.entries.push(CompletionSweepEntry {
23                    slot_id: entry.slot_id,
24                    observation: CompletionSweepObservation::Failed(error),
25                }),
26            }
27        }
28        receipt.retained_after = self.retained_count();
29        receipt.quarantined_after = self.quarantined_count();
30        Ok(receipt)
31    }
32}