How do I manage race conditions in Forge apps?

I’m making a Forge app but I have stumbled upon an obstacle.
Let’s say I have a business requirement that I can’t have more than 1 issue of the same issue type in each project. I could make a workflow validator in the Forge app that uses a JQL query to find out whether 1 issue of the same type already exists and if it does, it makes the validator fail. The problem comes up when 2 users try to create an issue of the same issue type in the same project. Both validations would pass at the same time and both issues would be created, thus resulting in an inconsistency in the business requirements.
How can I manage the race condition?

Absent an atomic global locking mechanism, this is not possible to solve. Even with goldilocks (punt intended), it could well come at great cost of performance and scalability. Welcome to the world of distributed system, my friend.

Having said that, many times it might worth asking about the reasons behind such “business” requirement. Get ready to be pleasantly amazed it’s a dictated solution rather than a requirement. Good luck!