Repository navigation
Conversation
A worker that fails a flush or compaction poisons the database and exits. A writer already waiting in local_backpressure, for sealed memtables or at the L0 write halt, then waited forever, since nothing would flush or compact again. Both loops now return Error::Poisoned, and insert, remove and batch commit pass it on to the caller. The tests force the failure with a read-only table folder.
Covers DatabaseInner::drop with a worker that exited on a failed flush, so the close never waits on a thread that is gone.
A worker that dies of an I/O error logs it, but not which keyspace it was working on. Put the keyspace in the flush and compaction failure logs.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
When a flush or compaction worker fails (for example, the volume fills up), the database is poisoned and the worker exits. A writer that is in
Keyspace::local_backpressureat that moment never comes back: both of its loops wait for workers to make progress, and neither checks the poison flag.sealed_memtable_count() >= 4) sleeps until a flush lowers the count, and a failed flush is never retried;check_write_halt,l0_run_count() >= 30) sleeps until a compaction lowers L0.We hit this downstream with a store reopened on a nearly full volume: a writer parked at 0% CPU in
local_backpressure, and freeing space afterwards did not wake it, so the process never exits and nothing reports why. A supervisor (a Kubernetes Job, systemd) can only act on a process that stops.Change
local_backpressurereturnscrate::Result<bool>. Both loops returnError::Poisonedonce the database is poisoned.Keyspace::insert,remove,remove_weak(throughmaintenance) andWriteBatch::commitpass the error on instead of completing the write.error).A write that reaches backpressure has already been journaled and applied to the memtable when it returns
Poisoned; the error does not roll it back. This matches how a persist failure is already reported for journaled writes.The close path needed no change: since 3.1.13,
DatabaseInner::dropdrains and usestry_send, so a dead worker no longer parks it. A regression test for that is included.Tests
tests/dead_worker.rs(Unix only; skipped when running as root, since it makes thetablesfolder read-only to force the worker failure):writers_in_backpressure_return_when_the_flush_fails: holds 4 sealed memtables, parks aninsertand a batch commit, then lets the flush fail. Both returnPoisonedwithin 10 s. Before the change they time out.close_returns_after_the_worker_died: regression test for the drop path.writer_at_the_write_halt_returns_when_the_compaction_fails: fills L0 to 30 runs and lets the compaction fail. This one depends on Resume compaction when L0 write halt has no pending work #326: onmainalone nothing requests a compaction at the halt, so the writer waits on that bug instead of reaching the poison check. It passes with Resume compaction when L0 write halt has no pending work #326 applied, and is marked#[ignore]here until Resume compaction when L0 write halt has no pending work #326 lands.cargo fmt --checkis clean andcargo testpasses onmainplus this branch (macOS); with #326 stacked, all three tests pass in about 1 s.Related: #326 (both touch
check_write_halt/local_backpressure; the conflict between them is trivial).Summary by CodeRabbit