Skip to content← All gravesR.I.P.
Two threads, one counter
–
“Both threads won. The counter lost.”
JavaRace condition
Death certificate
- Status
- 🪦 Buried
- Cause of death
- Race conditionTwo things happened in the wrong order. Only sometimes, and never with a debugger attached.
- Severity
- Critical
- Hours to kill
- 38 hours
- Killed by
- Jashanpreet
- Language
- Java
- Born
- 22 Apr 2025
- Fix merged
- 9 May 2025
- Buried
- 19 May 2025
- Component
- analytics
- Symptoms
- Under load, page-view counts came out lower than the real traffic.
- The fix
- Used an atomic increment instead of read, add, write.
Timeline
Every life of this bug, oldest first.
- 🐛
Born as “Two threads, one counter”22 Apr 2025
- 🩹
Fix merged9 May 2025
- 🪦
Buried19 May 2025