Skip to content

feat: disk-full handling for AOF writes#260

Merged
kacy merged 1 commit intomainfrom
feat/disk-full-handling
Feb 24, 2026
Merged

feat: disk-full handling for AOF writes#260
kacy merged 1 commit intomainfrom
feat/disk-full-handling

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Feb 24, 2026

summary

when AOF writes fail with ENOSPC (disk full), the shard now rejects subsequent write commands with ERR disk full, write rejected — free disk space to resume writes. reads and admin commands continue working so operators can inspect and recover. the flag auto-clears when disk space becomes available (detected on the periodic fsync tick or the next successful AOF write).

what was tested

  • all 491 unit tests pass (cargo test --workspace --exclude ember-integration-tests)
  • clippy clean on emberkv-core
  • new is_write_classifies_correctly test validates the read/write classification

design considerations

  • the disk_full flag is a simple bool per shard (not AtomicBool) since the shard runs single-threaded — no synchronization overhead on the hot path
  • log_aof_error now returns bool indicating disk-full, keeping the detection logic in one place
  • is_write() on ShardRequest uses an explicit match to be future-proof — new variants that aren't listed default to read (safe default)
  • blocking pop operations (BLPOP/BRPOP) propagate the disk_full flag through write_aof_record for consistency

when an AOF write fails with ENOSPC (disk full), the shard now sets a
`disk_full` flag that rejects all subsequent write commands with an
explicit error message. reads and admin commands still work so operators
can inspect and recover.

the flag clears automatically when a periodic fsync succeeds (every 1s
for the EverySec policy) or when a normal AOF write recovers, so the
server resumes accepting writes as soon as disk space is freed.

changes:
- add `is_write()` method to ShardRequest for classifying mutations
- add `disk_full` flag to shard state and ProcessCtx
- check flag before dispatching write commands in process_single
- `log_aof_error` now returns whether the error was disk-full
- set flag on ENOSPC, clear on recovery in both process_single and
  fsync tick paths
- propagate disk_full through write_aof_record for blocking pop ops
@kacy kacy merged commit 88bdc8d into main Feb 24, 2026
6 of 7 checks passed
@kacy kacy deleted the feat/disk-full-handling branch February 24, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant