Galaxy Legion Forum
http://galaxylegion.com/forum/

Fixing race conditions in GL database
http://galaxylegion.com/forum/viewtopic.php?f=5&t=18920
Page 1 of 1

Author:  BinaryMan [ Sun Jan 08, 2012 4:58 am ]
Post subject:  Fixing race conditions in GL database

Providing technical suggestion here, due to recent abuse that I won't go into. The problem with all game requests is not processing them sequentially for any particular player; therefore, I would recommend converting mySQL to innoDB instead of MyISAM and doing row level locking. The other solution is to queue requests made by the same player, but this is hard with PHP + MySQL. You want all game states updated before processing the next requests, so that the game logic will reject requests that are no longer valid (usually, exceeding a game counter or limit). This should also fix multiple base+boss drops which actually happens without anyone trying if there are a lot of people hitting it at the same time (again, parallel requests). If you lock the correct data related to a game request, it should prevent race conditions that result in unexpected game behaviors since the next request will only be processed in the database once the prior one is completed.

Author:  Missed [ Sun Jan 08, 2012 6:20 am ]
Post subject:  Re: Fixing race conditions in GL database

Yeah, this seems the clearest sure way to fix all these bugs to me as well. This is what I've been suggesting for like a year every time someone brings up a new bug based on this design flaw (which is basically the cause of 95% of all the bugs that have ever existed in this game). You implement locking and then create a locked/action denied handler for the front-end. It would create more delays/lag when doing things like attacking bases since I doubt the DB (given that most hosted DBs are slow as snot) could keep up with the current transaction speeds involved in large base combat but that could be alleviated by say adding a 50 energy attack button that does 10 attacks at once or something to reduce the queries.

Author:  Missed [ Sun Jan 08, 2012 6:55 am ]
Post subject:  Re: Fixing race conditions in GL database

This isn't necessarily the only way to fix it however just perhaps the most certain to avoid future similar bugs. The database semaphore style suggested http://galaxylegion.com/forum/viewtopic.php?f=7&t=18651 would also work. Or if the system runs some kind of master thread on the server you could do software semaphores instead of database semaphores like you would in a multi-threaded environment. Just throwing ideas out there to try and help get this taken care of.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/