Concurrent device registration without Redis
Summary
This article details solving a race condition in concurrent device registration without Redis by leveraging MySQL's row-level locking and transactions. It walks through multiple iterations (naive handler, global mutex, per-user mutex, and a database-backed lock using a dedicated lock table) and examines how isolation levels (READ COMMITTED vs REPEATABLE READ) affect correctness. The main takeaway is to use the existing durable store as coordination, selecting the right locking primitives and isolation level to guarantee correctness without added infrastructure.