Open codercms opened 3 years ago
Would be great if this is getting done. We currently have a lot of Deadlock issues:
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: update `pages` set `_lft` = case when `_lft` between 41 and 42 then `_lft`-7 when `_lft` between 34 and 42 then `_lft`+2 else `_lft` end, `_rgt` = case when `_rgt` between 41 and 42 then `_rgt`-7 when `_rgt` between 34 and 42 then `_rgt`+2 else `_rgt` end where (`_lft` between 34 and 42 or `_rgt` between 34 and 42))
@lazychaser what do you think about this issue? This issue affects all users. Do you have any plans for implementation?
Please use other locking mechanics like RedLock when performing updates on nodes to avoid dead locks. This package will only be updated to the latest versions of Laravel, no more features are added.
Does someone have a patch for this ?
Can this be workaround? At least for broken trees, not deadlocks.
Laravel Command that runs every minute or more often (latest Laravel supports Sub-minute Scheduling)
class FixTree extends Command
{
public function handle()
{
if(!Category::isBroken()) {
return;
}
Category::fixTree();
}
}
Because this package relies on calculations on the code side, the tree will always be in a broken state when simultaneously inserts are performed (duplicates by _lft will occur). I think this behavior should be documented.
To ensure concurrency safety this package should perform all calculations on the database side with row locking during update. For concurrency safe inserts, the following queries should be used (when
parent_id
is set):If
parent_id
is not set, the following queries should be used:Refs: