Skip to main content

compute_repairs

Function compute_repairs 

Source
pub(crate) fn compute_repairs(
    snapshot: &[(StateUpdateKindJson, Timestamp, Diff)],
) -> (Vec<(StateUpdateKindJson, Diff)>, RepairStats)
Expand description

Inspect a consolidated snapshot and return the updates needed to converge every affected Role onto a single canonical-form +1 (or zero rows, for the dropped case), and every untouched Role onto canonical form so future writers’ retractions consolidate.

The returned Vec is safe to feed straight into compare_and_append.

Two passes:

  1. For each dangling -1 Role row matching the v80-form-drift signature, cancel it (+1 of the same bytes) and retract every parsed-equal stale +1 sibling.
  2. For each remaining +1 Role row whose stored bytes don’t match the canonical re-serialization of its parsed value, retract it and insert the canonical form. Skipped for any RoleKey whose dangling -1 we declined to repair in pass 1 — partial rewriting there would manufacture a fresh dangling diff against the canonical form.

Separated from upgrade so it can be unit-tested without spinning up a real catalog handle.