- Feb 8, 2004
- 12,603
- 9
- 81
So I have written an update to our ticketing system. Is is built with php and uses mysql as the database and apache as the webserver.
A tech can have a single ticket active at a time. When a tech clicks a "set active" button an ajax request is sent from the browser to php. This should (and mostly does) result in a single database entry with the ticketid, the techid and the startdate which is a unix timestamp. But sometimes there are duplicate entries i.e there will be 4 rows with the same techid, ticketid and startdate. As if the tech has started the ticket 2 times at the exact same millisecond. Sometimes there are 3 or more duplicates.
What could be going on here? I have been over the code extensively and im pretty sure there is nothing wrong with the logic here. I even pushed an update that disables the "set active" button after the tech pushes it and when the ajax request returns it is enabled again to prevent techs hammering the button if it lags etc. But there are still duplicates happening
tl;dr Given mysql, php5.4 and apache, how can 1 ajax request that 99% of the time results in 1 database row entry sometimes result in multiple duplicate rows. Primary key is auto incremented so it is the only thing not duplicated.
This is a browser based ticket system, 6 servers and a load balancer.
A tech can have a single ticket active at a time. When a tech clicks a "set active" button an ajax request is sent from the browser to php. This should (and mostly does) result in a single database entry with the ticketid, the techid and the startdate which is a unix timestamp. But sometimes there are duplicate entries i.e there will be 4 rows with the same techid, ticketid and startdate. As if the tech has started the ticket 2 times at the exact same millisecond. Sometimes there are 3 or more duplicates.
What could be going on here? I have been over the code extensively and im pretty sure there is nothing wrong with the logic here. I even pushed an update that disables the "set active" button after the tech pushes it and when the ajax request returns it is enabled again to prevent techs hammering the button if it lags etc. But there are still duplicates happening
tl;dr Given mysql, php5.4 and apache, how can 1 ajax request that 99% of the time results in 1 database row entry sometimes result in multiple duplicate rows. Primary key is auto incremented so it is the only thing not duplicated.
This is a browser based ticket system, 6 servers and a load balancer.