Ferricstore.Store.DiskPressure (ferricstore v0.4.3)

Copy Markdown View Source

Per-shard atomic disk pressure flags.

When a Bitcask flush fails (e.g., ENOSPC), the shard sets its IO disk pressure flag. The operational guard can also set a separate capacity-derived pressure flag when the data directory crosses the configured reject ratio. The Router write path checks both sources before accepting writes, returning an error instead of silently queuing data that can't be persisted.

IO pressure is cleared when a flush succeeds. Operational pressure is cleared only by the operational guard once disk usage drops below reject level. The two sources are intentionally separate so proactive recovery never hides a real IO failure.

Uses :atomics for lock-free ~5ns reads from any process.

Summary

Functions

Clears disk pressure flag for a shard using instance ctx.

Clears capacity-derived operational disk pressure for a shard.

Sets disk pressure flag for a shard using instance ctx.

Sets capacity-derived operational disk pressure for a shard.

Checks disk pressure for a shard using instance ctx.

Functions

clear(shard_index)

@spec clear(non_neg_integer()) :: :ok

clear(ctx, shard_index)

@spec clear(FerricStore.Instance.t(), non_neg_integer()) :: :ok

Clears disk pressure flag for a shard using instance ctx.

clear_operational(shard_index)

@spec clear_operational(non_neg_integer()) :: :ok

Clears capacity-derived operational disk pressure for a shard.

init(shard_count)

@spec init(pos_integer()) :: :ok

set(shard_index)

@spec set(non_neg_integer()) :: :ok

set(ctx, shard_index)

@spec set(FerricStore.Instance.t(), non_neg_integer()) :: :ok

Sets disk pressure flag for a shard using instance ctx.

set_operational(shard_index)

@spec set_operational(non_neg_integer()) :: :ok

Sets capacity-derived operational disk pressure for a shard.

under_pressure?(shard_index)

@spec under_pressure?(non_neg_integer()) :: boolean()

under_pressure?(ctx, shard_index)

@spec under_pressure?(FerricStore.Instance.t(), non_neg_integer()) :: boolean()

Checks disk pressure for a shard using instance ctx.