MySQL race? (when a player takes anothers id while query is still running)
#1

Hello everyone,
I am following BlueGs example on using MySQL: https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn

I can't wrap my head around the MySQL race solution he has to the problem:
(lines: 234-236)
player A connects -> SELECT query is fired -> this query takes very long
while the query is still processing, player A with playerid 2 disconnects
player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player

He goes on to say the solution to this is:
(lines 239-242)
we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
we also pass the current value of the connection count to our OnPlayerDataLoaded callback
then we check if current connection count is the same as connection count we passed to the callback
if yes, everything is okay, if not, we just kick the player

I don't understand how this is going to stop the problem (I know it is a solution, but I don't understand it.).
I would really appreciate it if someone could put this in other words.
Thanks in advance!
Reply


Messages In This Thread
MySQL race? (when a player takes anothers id while query is still running) - by Seifspeed - 15.07.2018, 19:34
Re: MySQL race? (when a player takes anothers id while query is still running) - by Calisthenics - 15.07.2018, 19:56
Re: MySQL race? (when a player takes anothers id while query is still running) - by Seifspeed - 15.07.2018, 20:04

Forum Jump:


Users browsing this thread: 1 Guest(s)