Skip to main content

prune_history_cohort

Function prune_history_cohort 

Source
pub fn prune_history_cohort(
    db: &Db,
    schema: &RpcStoreSchema,
    pruned_checkpoint_watermark: u64,
    pruned_tx_seq_exclusive: u64,
    effects: &[(u64, TransactionEffects)],
) -> Result<()>
Expand description

Prune the embedded fullnode’s history cohort up to a floor supplied by the validator’s perpetual-store pruner.

Unlike start_pruner, this is not epoch-driven and not a Service. The embedded deployment deactivates the raw chain-data CFs (transactions, effects, events, objects, checkpoint_*), so it cannot derive a retention floor or read the raw effects itself. Instead the perpetual pruner — which owns the raw data — supplies the floor and the pruned checkpoints’ effects directly, and this prunes exactly the history-cohort CFs that grow without bound:

  • tx_metadata_by_seq — range-deleted over [old_tx_lo, pruned_tx_seq_exclusive).
  • tx_seq_by_digest — point-deleted; the digests are read from tx_metadata_by_seq (the only history CF that still carries them) over the pruned range, before that range is deleted.
  • object_version_by_checkpoint — retracted effects-driven through the same per-batch deduped retraction path as the standalone prune_chunk (the paired objects delete lives in that caller, not the helper, and the embedded store has no objects CF): each effect carries the checkpoint it was pruned from, and repeated retractions for one object are coalesced to the greatest checkpoint, so a superseded object keeps only its supersession-checkpoint row — the anchor a point-in-time read at the floor resolves to — and a removed object drops its rows (a later wrap/unwrap re-creation at or above the floor survives).
  • transaction_bitmap / event_bitmap — evicted by advancing the database-local tx_seq floor so their compaction filters drop fully-pruned buckets during periodic compaction.

The live cohort, package_versions, and the tiny epochs CF are never pruned.

pruned_checkpoint_watermark is the highest checkpoint the perpetual store has pruned (inclusive); pruned_tx_seq_exclusive is the first still-retained tx_seq. The pruner consumes the same floor the perpetual store prunes to, so the embedded rpc-store’s history cohort stays in lockstep with it. Idempotent: a re-run with the same or a lower floor is a no-op.

Ordering contract: the caller must invoke this BEFORE durably committing its own prune of the same checkpoints. The object_version_by_checkpoint retraction is driven by the effects passed in this call and is never re-derived; if the caller’s floor committed first, a crash between the two commits would skip these effects forever and leak the rows they retract. Committing this side first is safe precisely because a re-run is idempotent.