I have an API in which we expect a emailID and a certain deal data. The case is we want to keep the dealId and contactId(email) to be unique. Creating a deal requires data insertion in multiple tables.
data is first inserted in tb_contact_email. Then , it is inserted in tb_deals , tb_contacts and tb_contact_details
If two deal creation hits come simultaneously from the same contact , the second hit is able to ascertain that tb_contact_email record exists. However,the second hit is not able to find the record in tb_deals because the first call is still in the process.
We cannot ignore the second hit because we expect to create a note related to that deal from the second hit. How to handle this architecture problem.