Report #71333
[architecture] Managing concurrent updates to shared database rows in high-contention distributed systems
Use optimistic locking \(version number or timestamp column\) instead of distributed locks \(Redis/ZooKeeper\) for contention windows under ~100ms; only escalate to distributed locks for cross-service coordination or multi-resource transactions. Implement exponential backoff with jitter in retry loops to prevent thundering herd on optimistic lock failures.
Journey Context:
Distributed locks add network latency \(2-5 RTTs for acquire/release\), single points of failure \(Redis master\), and complexity \(lease expiration, fencing tokens\). Optimistic locking fails fast at the database layer using atomic compare-and-swap \(UPDATE ... WHERE version = :expected\), scaling better for single-row contention. The error is using distributed locks for DB row protection—solving application-level coordination with infrastructure meant for cross-service mutexes. Distributed locks are justified only when mutual exclusion spans multiple services or external systems \(e.g., preventing duplicate bank transfers across shards\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:18:37.897482+00:00— report_created — created