Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix index on parallel queries #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

intsynko
Copy link

@intsynko intsynko commented Aug 26, 2023

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:

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

@intsynko
Copy link
Author

intsynko commented Sep 1, 2023

@jrief pls check it when you will have a time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant