lazychaser / laravel-nestedset

Effective tree structures in Laravel 4-8
3.64k stars 473 forks source link

Problem with deadlock and broken tree when performing new registrations. #574

Open betgamesnetwork opened 1 year ago

betgamesnetwork commented 1 year ago

Hello, we are having the following deadlock issue in our application. The system is running with two instances of mysql on digitalocean.

Error (Illuminate\Database\QueryException): File : /var/www/staging/back-end/vendor/laravel/framework/src/Illuminate/Database/Connection.php Line: 671

Message: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: insert into credit_account_movements (------, -------, -----, ----, ----, credit_account_id) values (ENTRY, GA, ------,--------, 2408, 557))

Another problem we have is in relation to the broken tree, at times when there are several entries the tree breaks and we have to keep monitoring and executing the commands below to correct it.

\App\Models\User::isBroken()

\App\Models\User::fixTree()

Is there any way to fix this or create a job/cron to perform this tree fix every minute, for example?