Skip to content

Fix preconditions in transactions #1980

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

Merged
merged 5 commits into from
Jul 13, 2019
Merged

Fix preconditions in transactions #1980

merged 5 commits into from
Jul 13, 2019

Conversation

thebrianchen
Copy link

@thebrianchen thebrianchen commented Jul 11, 2019

Context: b/135709736
Currently, if you read a non-existent document, then modify the document twice in the same transaction, each Write will include a precondition that the document did not exist. The server will reject this sequence since each precondition is applied on top of preceding writes in the transaction.

Instead, for the first write to a given key, generate a precondition that takes into account the read time and existence of the document, as we do today. For subsequent writes to a given key, generate a general precondition that only preserves the semantics of the operation: set() and delete() use Precondition(none) and update() uses Precondition(exists).

  • Update precondition logic to buganizer spec.
  • Reorder public and private methods in transaction.ts.
  • Add table tests for testing transaction combinations.

…vate methods in transaction, add table tests
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

@thebrianchen thebrianchen requested a review from wilhuff July 11, 2019 23:54
@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff Jul 12, 2019
@thebrianchen thebrianchen assigned wilhuff and unassigned thebrianchen Jul 12, 2019
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks great!

A few final nits and an optional change to move fully to async/await if you wanted.

@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff Jul 12, 2019
@thebrianchen thebrianchen merged commit 4e3ebca into master Jul 13, 2019
@thebrianchen thebrianchen deleted the bc/precondition branch July 13, 2019 00:08
@firebase firebase locked and limited conversation to collaborators Oct 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants