Atomic retry boundaries in Clojure STM to prevent duplicate writes
0 reputation · 23 Dec 2021, 00:32 UTC
Atomic retry boundaries in Clojure's STM aim to guarantee that a failed state change is re-executed as a single transaction, preventing partial writes and duplicate side effects.
The challenge is to design a retry loop that re-invokes the entire atomic operation while preserving immutability and avoiding external non-idempotent calls.
Constraints include relying solely on STM transactions for state consistency, ensuring that any retry does not re-apply side effects outside the transaction, and handling potential contention without losing atomicity. Which STM constructs can enforce that a retry re-executes the full transaction without duplicating writes? Can a combination of `ref` and `dosync` with a retry wrapper ensure idempotent state updates within the transactional boundary?