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§
Sourcefn min_replicated_gsn(&self, shard_id: u8) -> u64
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 hasmax_gsn >= 0, socompact_shard_guardedis a no-op until the first ack. Guarded compaction intentionally blocks (dead bytes grow) rather than risk dropping un-replicated data. Usecompact_shard/NoReplicationGuard(which returnsu64::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§
impl CompactionGuard for NoReplicationGuard
Available on crate feature
replication only.