zieren / wasted-youth-tracker

Limit kids' time on their (Windows) PC and get a summary of the window titles.
GNU General Public License v3.0
5 stars 0 forks source link

Prevent deadlocks #129

Open zieren opened 2 months ago

zieren commented 2 months ago

It seems client requests and reclassification happening at the same time trigger a deadlock:

[critical] Error: {"type":1,"message":"Uncaught mysqli_sql_exception:
Deadlock found when trying to get lock; try restarting transaction in ...db.class.php:682
Stack trace:
...
#7 ...RX.php(66): Wasted::insertActivity('user', '', Array)
#8 ...rx\/index.php(10): RX::handleRequest('user\\n\\nAPP Cente...')\n#9 {main}\n  thrown"...

Generally one can reorder locks, but this is probably done by MeekroDB internally. Maybe simly wrap the relevant reclassification commands in a transaction?