fix: multi-publisher slot livelock — replace CAS loop with fetch_add claiming

#35 · closed · 0 comments

View on GitHub ↗

userFRM

## Problem commit_to_ring uses a CAS loop to acquire ring slots in multi-publisher mode. If a publisher crashes holding SEQ_WRITING, the slot is permanently stuck. The current 1M-iteration cap is a band-aid — it force-claims after spinning for ~10ms. ## Fix Replace the CAS-based slot locking with fetch_add sequence claiming (like the single-publisher path already does). Each publisher atomically claims a unique sequence number, then writes to its slot without contention. No CAS loop, no livelock possible. ## Design - Publishers claim seq via `write_seq.fetch_add(1, AcqRel)` (already done) - The seqlock sentinel `SEQ_WRITING` is still needed to tell subscribers the slot is being written - But the CAS loop that waits for SEQ_WRITING to clear can be replaced: if the slot is still WRITING from a previous seq, it means the old publisher crashed — just overwrite it

Comments