When you draging several lines in few seconds and parallel request running to change position - its raise an unrepetable reading and the sort index in database became not unique. For example we have an table:
a 1
b 2
c 3
d 4
e 5
and two parallel requests
POST adminsortable2_update: startorder: 2, endorder: 4
POST adminsortable2_update: startorder: 5, endorder: 3
after first requests table will be:
a 1
b 4
c 2
d 3
e 5
after second request table will be:
a 1
b 4
c 4
d 5
e 3
Problem is duplicating sort index 4 in table.
It apperas becouse second request had read table before changes from first query was applied - so second request moved e to 3d position and changed indexes for d and c as +1.
Solition
To avoid this case we will lock all the range of changable rows
Fix sorting in parallel requests
Problem:
When you draging several lines in few seconds and parallel request running to change position - its raise an unrepetable reading and the sort index in database became not unique. For example we have an table:
and two parallel requests
POST
adminsortable2_update: startorder: 2, endorder: 4POST
adminsortable2_update: startorder: 5, endorder: 3after first requests table will be:
after second request table will be:
Problem is duplicating sort index
4
in table. It apperas becouse second request had read table before changes from first query was applied - so second request movede
to 3d position and changed indexes ford
andc
as +1.Solition
To avoid this case we will lock all the range of changable rows