A data race that doesn't compile (in Rust)
How I taught Rustβs type system to refuse my own parallel-Redux data races, with one false start and one mind-shift.
Thereβs a class of bug Iβve spent more nights chasing than I care to remember. The kind that only happens under load, vanishes when you attach a debugger, and takes three engineers a weekend to corner. Data races.
Rustβs borrow checker prevents most of them at the value level. But not all of them, and definitely not the question that interested me here: can the compiler refuse to build a parallel reducer pipeline where two reducers might write to the same piece of state?
Turns out yes. This post is the story of how I got there in ruxe , my Redux-flavored Rust learning library.
Redux is a state management pattern. It got famous in frontend JavaScript but the shape is more general; any system where state changes through discrete events fits the model.
One: a single source of truth. The state is owned by the store, nothing else.