i am coding something like omegle random chat i have a table called chat_users in which
i am storing ppl who are not chating with anyone they just come then i wil delete them when they start chating with other ppl
lets say
we have users named uid1,uid2,uid3
at a 1:05 and 5 sec(one any perticular time) uid1 request to chat with uid2 and get removed from table
but at that same time uid3 also got uid2 as random result then it wil be problem
cause uid2 doesnt exist its chating with uid1
how can i solve this issue??
Use transactions.
Clarification: Wrap the selection of the random result and the following deletion in a transaction and the problem will go away because mySQL then should take care of colliding transactions.