I am working on a multiplayer game in which there is a lobby where players select "sectors" to enter. The lobby gateway runs on PHP, and the actual gameplay is handled by one or more Java servers. MySQL data warehouse.
Happy Way: The player chooses a sector and tells the lobby that he would like to enter. The lobby checks if everything is in order, including checking if there are too many players in this sector (compares the number of entries in the industry assignments of this sector against the max_players value in the sector). The player is added to the Sector_assignments table, connecting it to the sector. Client-client receives an access key that will allow him to connect to the corresponding game server.
Race Status: If two players request access to the same sector at the same time, I can imagine the case when they were both added because there was one free space when their check was started and the maximum number of players was exceeded.
Is the best LOCK TABLE solution for sectors? Is there any other option?
source
share