Ferricstore.Store.DiskPressure (ferricstore v0.3.6)

Copy Markdown View Source

Per-shard atomic disk pressure flags.

When a Bitcask flush fails (e.g., ENOSPC), the shard sets its disk pressure flag. The async write path in Router checks this flag before accepting writes, returning an error instead of silently queuing data that can't be persisted.

The flag is cleared when a flush succeeds, allowing writes to resume automatically once disk space is available (e.g., after compaction reclaims space or an operator adds storage).

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

Summary

Functions

Clears disk pressure flag for a shard using instance ctx.

Sets disk pressure flag for a shard using instance ctx.

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.

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.

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.