MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / prepare_checkpoint

Function prepare_checkpoint

libatomic/src/daemon/provenance_core.rs:144–169  ·  view source on GitHub ↗

Freeze the journal frontier and persist one recoverable checkpoint attempt, with the legacy `reuse_frozen_changes` recovery: a previous Stop may have recorded the change before its journal read failed. The retry sees a clean working copy; recover only those frozen hashes, then retain the store's source validation — a new nonempty change set must still conflict.

(
    store: &RedbChangeStore,
    id: ProvenanceId,
    expected_generation: u64,
    mut source: ProvenanceCheckpointSource,
    reuse_frozen_changes: bool,
    now: i64,
)

Source from the content-addressed store, hash-verified

142/// retain the store's source validation — a new nonempty change set must
143/// still conflict.
144pub fn prepare_checkpoint(
145 store: &RedbChangeStore,
146 id: ProvenanceId,
147 expected_generation: u64,
148 mut source: ProvenanceCheckpointSource,
149 reuse_frozen_changes: bool,
150 now: i64,
151) -> Result<ProvenanceCheckpointAttempt, JournalError> {
152 let attempt = (|| {
153 if reuse_frozen_changes && source.change_hashes.is_empty() {
154 if let Some(turn) = store.get_provenance_turn(id)? {
155 if turn.generation == expected_generation
156 && matches!(turn.state, ProvenanceTurnState::Checkpointing)
157 {
158 if let Some(attempt) = turn.checkpoint_attempt {
159 source.change_hashes = attempt.source.change_hashes;
160 }
161 }
162 }
163 }
164 store.prepare_provenance_checkpoint(id, expected_generation, source, now)
165 })()
166 .map_err(|error| JournalError::store(ErrorCode::ProvenanceCheckpoint, error))?;
167 owner_failpoint("after-checkpoint-prepare");
168 Ok(attempt)
169}
170
171/// The encoded size of one empty frozen-page response frame: the protobuf
172/// message plus the 5-byte gRPC length-prefix. The budget reserves this

Callers 1

prepare_checkpoint_implFunction · 0.85

Calls 5

storeFunction · 0.85
owner_failpointFunction · 0.85
get_provenance_turnMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected