Skip to main content

Posts

Showing posts with the label Billing Systems

๐Ÿ” "Billing Gone Wrong: How Lack of Synchronization Led to Swapped Bills (And What I Learned!)"

☕ A Walk Down Memory Lane: My First Bug Nightmare About 9 years ago, as a fresher, I worked on a billing system for a retail application. The system was accessed both from mobile and web UI , and the actual billing logic was written in stored procedures (SQL-based backend). Everything looked fine... until customers started reporting weird issues : ๐Ÿ› The Bug: Bills Were Swapping Items! ๐Ÿ˜ฑ ๐Ÿงพ Scenario: Two different users generated separate bills around the same time One from Mobile , the other from Web The output bills had mixed-up items — each invoice had products that belonged to the other one! ๐Ÿงจ ๐Ÿ” Initial Questions: "Is this a DB issue?" "Are stored procedures broken?" "Race condition in app layer?" Turns out... ๐Ÿšซ The code calling stored procedures wasn’t thread-safe. There was no synchronized mechanism to ensure each bill transaction was isolated. ๐Ÿง  The Root Cause Analysis (RCA): We were calling a shared BillingService.calculat...