Skip to content

Add words about read refreshing to the transaction design page #2684

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 1 commit into from
Mar 9, 2018

Conversation

andreimatei
Copy link
Contributor

No description provided.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@andreimatei
Copy link
Contributor Author

cc @jordanlewis who requested some docs for the refreshing

@cockroach-teamcity
Copy link
Member


2. `TxnB` tries to push `TxnA`'s timestamp forward.

This succeeds only in the case that `TxnA` has snapshot isolation and `TxnB`'s operation is a read. In this case, the [write skew](https://en.wikipedia.org/wiki/Snapshot_isolation) anomaly occurs.

3. `TxnB` enters the `PushTxnQueue` to wait for `TxnA` to complete.

Additionally, the following types of conflicts that don't involve running into intents can arise:

- **Write after read**, when a write with a lower timestamp encouters a later read. This is handled through the [Timestamp Cache](#timestamp-cache).
Copy link
Member

Choose a reason for hiding this comment

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

s/encouters/encounters/

Additionally, the following types of conflicts that don't involve running into intents can arise:

- **Write after read**, when a write with a lower timestamp encouters a later read. This is handled through the [Timestamp Cache](#timestamp-cache).
- **Read within uncertainty window**, when a read encounters a value with a higher timestamp but it's ambiguous whether the value should be considered to be in the future or in the past of the transaction because of possible *clock skew*. This is handled by attempting to push the transaction's timestamp beyond the uncertain value (see [read refreshing](#read-refreshing)).
Copy link
Member

Choose a reason for hiding this comment

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

s/attempting to push.../attempting to forward the transaction's timestamp just beyond the uncertain value's timestamp/ (I don't think push is right in this context).

You might also add: "If the transaction timestamp forwarding and refreshing is unsuccessful, then the transaction must be retried at the forwarded timestamp. Note that on successive retries, reads will never encounter uncertainty issues on any node which was previously visited."


### Read Refreshing

Whenever a transaction's timestamp has been pushed, additional checks are required before allowing serializable transactions to commit at the pushed timestamp: we need to check that whatever the transaction has previously read at its original timestamp hasn't changed before the pushed timestamp. This is done by keeping track of all the reads using a dedicted `RefreshRequest`. If this succeeds, the transaction is allowed to commit (technically, transactions perform this check at commit time if they've been pushed by a different transaction or by the timestamp cache, or they perform the check whenever they encounter a `ReadWithinUncertaintyIntervalError` before continuing).
Copy link
Member

Choose a reason for hiding this comment

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

I would re-word this to remove the use of first person pronouns ("we"). How about:

"any values which the transaction previously read must be checked to verify that no writes have subsequently occurred between the original transaction timestamp and the forwarded transaction timestamp. This check prevents serializable isolation violations."

s/dedicted/dedicated/

s/technically, transactions/usually transactions/
s/before continuing/immediately, before continuing/

@jordanlewis
Copy link
Member

@andreimatei thanks for embarking on this effort.

@andreimatei
Copy link
Contributor Author

Review status: 0 of 1 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


v2.0/architecture/transaction-layer.md, line 152 at r1 (raw file):

Previously, spencerkimball (Spencer Kimball) wrote…

s/encouters/encounters/

Done.


v2.0/architecture/transaction-layer.md, line 153 at r1 (raw file):

Previously, spencerkimball (Spencer Kimball) wrote…

s/attempting to push.../attempting to forward the transaction's timestamp just beyond the uncertain value's timestamp/ (I don't think push is right in this context).

You might also add: "If the transaction timestamp forwarding and refreshing is unsuccessful, then the transaction must be retried at the forwarded timestamp. Note that on successive retries, reads will never encounter uncertainty issues on any node which was previously visited."

why isn't "push" the right word? That's what we generally use when we talk about a transaction's timestamp being changed. I understand what we discussed the other day - about how, in the case of writes running into the timestamp cache the transaction can continue reading at its old timestamp, but in the case of uncertainty errors, the txn needs to immediately start reading at the new timestamp, but I don't think these considerations make "push" not valid...

I've incorporated your addendum, but I've split it between here and the refresh section.


v2.0/architecture/transaction-layer.md, line 182 at r1 (raw file):

Previously, spencerkimball (Spencer Kimball) wrote…

I would re-word this to remove the use of first person pronouns ("we"). How about:

"any values which the transaction previously read must be checked to verify that no writes have subsequently occurred between the original transaction timestamp and the forwarded transaction timestamp. This check prevents serializable isolation violations."

s/dedicted/dedicated/

s/technically, transactions/usually transactions/
s/before continuing/immediately, before continuing/

Done.


Comments from Reviewable

@cockroach-teamcity
Copy link
Member

@andreimatei andreimatei merged commit a436e99 into cockroachdb:master Mar 9, 2018
@andreimatei andreimatei deleted the txn branch March 9, 2018 21:07
@petermattis
Copy link
Contributor

Review status: 0 of 1 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


v2.0/architecture/transaction-layer.md, line 182 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

Done.

I thought the reads were tracked at the TxnCoordSender (or whatever it is now) and "refreshed" using RefreshRequest. The wording above makes it sound like the RefreshRequest is doing the tracking. Admittedly, I'm not familiar with the code, so perhaps the above is accurate.


Comments from Reviewable

@andreimatei
Copy link
Contributor Author

Review status: 0 of 1 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


v2.0/architecture/transaction-layer.md, line 182 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

I thought the reads were tracked at the TxnCoordSender (or whatever it is now) and "refreshed" using RefreshRequest. The wording above makes it sound like the RefreshRequest is doing the tracking. Admittedly, I'm not familiar with the code, so perhaps the above is accurate.

There's a missing word indeed; I wanted to say "keeping track of all the reads and using a dedicated RefreshRequest"
Will amend, thanks.


Comments from Reviewable

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.

6 participants