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

Avoid race condition between predicate move and commit #2392

Merged
merged 9 commits into from
May 16, 2018

Conversation

manishrjain
Copy link
Contributor

@manishrjain manishrjain commented May 16, 2018

  • The reason for bug Inserts can be lost during a predicate move #2338 was that there was a race condition between a mutation and predicate move. Zero was not checking if a predicate is under move before allowing a commit. Thus, a mutation could get proposed in a group, then a move starts, and get committed by Zero (after the move starts).
  • This change this issue by ensuring that Zero checks if a predicate is being moved, before allowing commit.
  • Any pending transactions are also cancelled once the move starts, so this would only happen as part of a race condition and not afterward.

Mechanism:

  • Send the real keys back to Zero, as part of Transaction Context.
  • Zero uses these keys to parse the predicate, and checks if that predicate is currently moving. If so, it would abort the transaction.
  • Also, check for _predicate_ being moved. For some reason, if we don't consider this predicate, we could still lose data.
  • Before doing a mutation in Dgraph alpha, check if that tablet can be written to.
  • Loop until all transactions corresponding to the predicate move are aborted. Only then start the move.

Tangential changes:

  • Update the port number for bank integration test.
  • Remove the separate key value or clean channel. Make it run as part of the main Node.Run loop.
  • Add a max function.
  • Small refactoring here and there.

This change is Reviewable

@manishrjain manishrjain changed the title Avoid race condition between predicate move and commit (Fixes #2338) Avoid race condition between predicate move and commit May 16, 2018
@manishrjain manishrjain merged commit 339c47e into master May 16, 2018
@manishrjain manishrjain deleted the mrjn/predicate-move branch May 16, 2018 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant