Handling Billing Race Conditions and Duplicate Bill Number Issues

Posted by retro_rude007@reddit | ExperiencedDevs | View on Reddit | 16 comments

I’ll keep it short. I’ve been working on a billing race condition issue for the past 1 month. There are duplicate bill numbers being generated, and some bill numbers are getting skipped.

We don’t have a tester and cannot afford Kafka, so I used Redis + BullMQ to replicate a queue for processing bills. However, this has made the process slower. My plan was to let the system stabilize with this slower version and then move to a faster version later.

The issue, though, still persists. I test it on my system as much as I can, but whenever it goes live, it fails. I understand that there is a huge difference between local testing and production environments, but I don’t know how to ensure this doesn’t happen again.

Honestly, I’m at my wits’ end. My manager scolds me every day for it, and I feel stuck with no clear way out.