Race condition when running create API

Hi fellow Bubblers,

I’m working with an API that allows creating multiple sub-members under a single super member. Each super member is allowed a maximum of 2 sub-members.

I’ve already implemented logic to check if a super member has 2 or more sub-members and terminate the workflow in that case. However, this doesn’t seem to work properly when a super member opens multiple devices or tabs and tries to create sub-members at the same time — sometimes it still ends up creating more than 2.

(See attached image for context.)


How can I fix this concurrency issue to ensure a super member can’t exceed the limit, even with simultaneous requests?

Many thanks in advance!

I haven’t read it through yet, but this topic might contain what you are looking for