Page 1 of 1

mysql_deadlock_restart_transaction

Posted: 15 April 2013, 12:33
by pikiou
I playtested my game with someone on another computer, and each time I got a white screen with this message:

Code: Select all

Sorry, an unexpected error has occured ...

mysql_deadlock_restart_transaction

#0 /home/pikiou/gearnpiston/gearnpiston.game.php(783): APP_DbObject::DbQuery('REPLACE propert...')
#1 /home/pikiou/gearnpiston/gearnpiston.game.php(185): Gearnpiston->saveProperties()
#2 /var/tournoi/release/tournoi-130118-1659-gs/www/game/module/table/table.game.php(74): Gearnpiston->getAllDatas()
#3 /var/tournoi/release/tournoi-130118-1659-gs/www/view/common/game.view.php(176): Table->getAllTableDatas()
#4 /var/tournoi/release/tournoi-130118-1659-gs/www/view/common/game.view.php(135): game_view->post_generate()
#3 /var/tournoi/release/tournoi-130118-1659-gs/www/view/common/game.view.php(176): Table->getAllTableDatas()
#4 /var/tournoi/release/tournoi-130118-1659-gs/www/view/common/game.view.php(135): game_view->post_generate()
#5 /var/tournoi/release/tournoi-130118-1659-gs/www/view/common/ebg.view.php(23): game_view->generate_content(Array)
#6 /var/tournoi/release/tournoi-130118-1659-gs/www/include/webActionCore.inc.php(178): ebg_view->generate(Array)
#7 /var/tournoi/release/tournoi-130118-1659-gs/www/index.php(126): launchWebAction('gearnpiston', 'gearnpiston', '__default', false, false, NULL, true)
#8 {main}
A deadlock happens when two scripts try to modify the same table at the same time and the mysql server is configured to only allow one at a time.
A refresh did the trick, but I'm wandering: will this only happen in the studio or do I have to loop repeat all my DB queries just in case?

Re: mysql_deadlock_restart_transaction

Posted: 15 April 2013, 13:28
by Alkazar
Is your table InnoDb or MyIsam(not sure what is the default) ?
If it's not, it should be Innodb.
In InnoDb, a deadlock happens if a user 1 locks a row X in table A , user 2 locks a row Y in table B(could be the same table) and then 1 tries to get a lock on row Y of table B (no deadlock yet), and 2 tries to get a lock on row X of table A. Do you see if it can happen in your game logic ?
Anyway, deadlocks are resolved automatically, and the only thing you should do try to avoid succession of queries which could end in deadlocks, but never retries the query on it's own.

Re: mysql_deadlock_restart_transaction

Posted: 15 April 2013, 13:58
by pikiou
Table engine was correctly InnoDB but your explanation made it clear what was wrong, thanks a lot!
Two users were updating the same set of rows but in a random order, hence the mutual block.