I’ve obviously missed something somewhere.
In some way a customer has managed to do a booking twice within a 11 seconds delay (checked time). My first though was that the user might have done the booking, then backed in the browser and done the booking again. However this is not possible since I had at least 2 validations which I know would prevent this behavior.
The only conclusion left for me is if the customer tried to submit a booking, our webservice somehow froze in maybe 11 seconds, the customer aborted the request and submited again, therefor allowing these 2 bookings to happend at the same moment.
Apart from that, I got no idea what could cause it. Delay in MySQL insert perhaps?
So basicly what I wonder mostly is;
What can cause a form to get submited and executed twice, with the second one bypassing all required validation?
Current workflow of my form
A user submits data in input fields, and then submits them. My system validates all of these inputs and check for both a unique code to make sure that it’s not used twice through a MySQL call. It also makes sure the number of seats available is equal or greator than then amount of seats booked.
In this mentioned case, both the same code was used and the seats over extended allowed limit.
Basicly the booking won’t be inserted into MySQL unless the POST is validated.
Sounds like you have a concurrency issue. Do you lock the table while doing the checks/insert?
In theory, if two executions occur at the same time, they will both have a unique ID and be within the seat limit, so both insertions will be allowed to proceed (and thus succeed).
Here is a diagrammatic way of what I am thinking:
The second make
POST 2should not be allowed to begin it’s unique ID check until the table is unlocked, i.e.POST 1has finished it’s insert.