Skip to main content

CompactionGuard

Trait CompactionGuard 

Source
pub trait CompactionGuard: Send + Sync {
    // Required method
    fn min_replicated_gsn(&self, shard_id: u8) -> u64;
}
Expand description

Guard that prevents compaction from removing files with unreplicated entries.

Required Methods§

Source

fn min_replicated_gsn(&self, shard_id: u8) -> u64

Minimum GSN replicated to all followers for this shard. Files containing entries with GSN above this value must not be compacted.

§Watermark policy

The value starts at 0 and advances monotonically (fetch_max) from a connected follower’s acks; it never decreases and carries no follower identity. This yields two deliberate extremes (see docs/design.md, “Политика min_replicated_gsn watermark”):

  • No follower ever acked → 0: every file has max_gsn >= 0, so compact_shard_guarded is a no-op until the first ack. Guarded compaction intentionally blocks (dead bytes grow) rather than risk dropping un-replicated data. Use compact_shard / NoReplicationGuard (which returns u64::MAX) when no follower is expected.
  • Replacement/fresh follower: the watermark still reflects the old follower’s progress. This is safe because catch-up emits a GSN-sorted stream (k-way merge in ShardLogReader), so the client’s stale-GSN watermark stays correct even over files compacted before the fresh follower connected.

Follower-identity reset and a no-ack compaction timeout are policy knobs left unimplemented until a concrete deployment needs them.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CompactionGuard for NoReplicationGuard

Available on crate feature replication only.
Source§

impl CompactionGuard for ReplicationServer