-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
roachpb: introduce QueryIntent request #26335
roachpb: introduce QueryIntent request #26335
Conversation
Review status: all files reviewed at latest revision, all discussions resolved, all commit checks successful. pkg/roachpb/api.go, line 1060 at r1 (raw file):
Comment that this only updates the read TS cache sometimes (and a reference to the code below) pkg/roachpb/api.proto, line 797 at r1 (raw file):
s/throw/return/ pkg/roachpb/api.proto, line 810 at r1 (raw file):
👍 pkg/roachpb/api.proto, line 816 at r1 (raw file):
I'm not sure we would ever want both - if an error is returned, the rest of the batch is failed, so we wouldn't reliably prevent all the intents if any of them encountered an error. pkg/roachpb/api.proto, line 825 at r1 (raw file):
I think it's fine to not return a TxnMeta, since the caller is required to pass in a TxnMeta. Does a pkg/roachpb/errors.proto, line 384 at r1 (raw file):
Document this. Why do we echo the caller's TxnMeta back to them? If we need a TxnMeta here, maybe we should include one in the QueryIntentResponse. pkg/storage/replica.go, line 2089 at r1 (raw file):
No, I don't think setting WriteTooOld is required here. WriteTooOld forces transaction restarts because there is known to be a conflicting write; to prevent the writing of an intent the read timestamp cache is sufficient and a bit cheaper. pkg/storage/batcheval/cmd_query_intent.go, line 59 at r1 (raw file):
Is the Comments from Reviewable |
c3b6e33
to
42df0a8
Compare
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. pkg/roachpb/api.go, line 1060 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/roachpb/api.proto, line 797 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/roachpb/api.proto, line 816 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Good point. I'll keep this as is. pkg/roachpb/api.proto, line 825 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I don't think we need to make this distinction, at least for any of our proposed uses of this request. If a client needs to prevent a missing intent then it will use the pkg/roachpb/errors.proto, line 384 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. And added the incorrect intent that was found, if any, to give the error message more color. pkg/storage/replica.go, line 2089 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
This depends on what we mean by "prevent the writing of an intent". I'm realizing (see Removed this comment. pkg/storage/batcheval/cmd_query_intent.go, line 59 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
The epoch should have been The sequence number is the only interesting case where we want more than exact equality. See the parallel commits RFC or the command I added to Comments from Reviewable |
Review status: 0 of 13 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. pkg/storage/batcheval/cmd_query_intent.go, line 59 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
I think the Timestamp comparison is off here and in the parallel commits RFC. I think it actually should be checking that the intent has a timestamp that is "less than or equal to" the txn's provisional commit timestamp. The reason for this is that a txn's intents don't need to be at its commit timestamp to allow it to commit, they just need to be at a timestamp equal to or less than its commit timestamp. This comes up with write pipelining because a batch may have its timestamp bumped after it laid down intents but from the point of view of the txn coordinator it's unclear which of its intents were laid down at which timestamp. If the txn refreshes successfully then its intents, even at older timestamps, are still valid and a QueryIntent request should still see them. Likewise, for parallel commits, a pusher trying to prevent a transaction from committing needs to prove that the transaction has failed to lay down an intent that it promises to write before committing. If the pusher finds an intent with the same sequence number but a smaller timestamp then bumping the timestamp cache won't do anything from the point of view of the committing transaction. In its eyes, it has laid down a "committable" intent. cc. @tschottdorf to double check this reasoning. Comments from Reviewable |
Nathan, that checks out. Thanks for noticing.
On Sat, Jun 9, 2018, 1:38 AM Nathan VanBenschoten ***@***.***> wrote:
Review status: 0 of 13 files reviewed at latest revision, 8 unresolved
discussions, some commit checks failed.
------------------------------
*pkg/storage/batcheval/cmd_query_intent.go, line 59 at r1
<https://reviewable.io/reviews/cockroachdb/cockroach/26335#-LEAz6aaD5GiwQ2N0o5L:-LEWi_VA9CDxy_9Dt_eF:b-8q5sca>
(raw file
<https://github.com/cockroachdb/cockroach/blob/c3b6e33acf0394e62f22c2f03f3dc0a3d9de3d3c/pkg/storage/batcheval/cmd_query_intent.go#L59>):*
*Previously, nvanbenschoten (Nathan VanBenschoten) wrote…*
The epoch should have been ==. This was also missing the very important
Timestamp comparison, which is necessary because an intent that has a
larger timestamp than expected must have been pushed and should not count
as a matching intent.
The sequence number is the only interesting case where we want more than
exact equality. See the parallel commits RFC
<https://github.com/tschottdorf/cockroach/blob/a2a46fce6d36f376b20868ed8283a14766436275/docs/RFCS/20180324_parallel_commit.md#preventintentrequest>
or the command I added to QueryIntentRequest.Txn for a discussion on why.
I think the Timestamp comparison is off here and in the parallel commits
RFC. I think it actually should be checking that the intent has a timestamp
that is "less than or equal to" the txn's provisional commit timestamp. The
reason for this is that a txn's intents don't need to be at its commit
timestamp to allow it to commit, they just need to be at a timestamp equal
to or less than its commit timestamp.
This comes up with write pipelining because a batch may have its timestamp
bumped after it laid down intents but from the point of view of the txn
coordinator it's unclear which of its intents were laid down at which
timestamp. If the txn refreshes successfully then its intents, even at
older timestamps, are still valid and a QueryIntent request should still
see them.
Likewise, for parallel commits, a pusher trying to prevent a transaction
from committing needs to prove that the transaction has failed to lay down
an intent that it promises to write before committing. If the pusher finds
an intent with the same sequence number but a smaller timestamp then
bumping the timestamp cache won't do anything from the point of view of the
committing transaction. In its eyes, it has laid down a "committable"
intent.
cc. @tschottdorf <https://github.com/tschottdorf> to double check this
reasoning.
------------------------------
*Comments from Reviewable
<https://reviewable.io/reviews/cockroachdb/cockroach/26335>*
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#26335 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE135N3jUbt_jrSY7elv1JLLIArR8wTZks5t6wsKgaJpZM4UXV6g>
.
--
…-- Tobias
|
Reviewed 13 of 13 files at r2. pkg/roachpb/api.proto, line 797 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Change the constant too. pkg/roachpb/api.proto, line 749 at r2 (raw file):
Update this comment with the new rules for timestamp matches. pkg/roachpb/errors.proto, line 384 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Why do we need to return this at all since it was a part of the request? pkg/storage/replica.go, line 2089 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Yes, I think we just mean "prevent writing an intent at this timestamp", so the read timestamp cache is sufficient. Comments from Reviewable |
42df0a8
to
8d57224
Compare
I updated this change with the new timestamp rule. I also made two other changes:
PTAL. Review status: complete! 0 of 0 LGTMs obtained pkg/roachpb/api.proto, line 797 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/roachpb/api.proto, line 749 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/roachpb/errors.proto, line 384 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/replica.go, line 2089 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. Comments from Reviewable |
8d57224
to
b2a8f75
Compare
This change introduces a new request method called QueryIntent. The request type draws parallels to the QueryTxn method, but it visits an intent instead of a transaction record and returns whether the intent exists or not. The request type also includes an "if missing" behavior, which allows clients to optionally ensure that the request prevents a missing intent from ever being written or return an error if the intent is found to be missing. This request type was proposed/discussed in both cockroachdb#24194 and cockroachdb#16026. It is a prerequisite for either proposal. Release note: None
Reviewed 8 of 8 files at r3. Comments from Reviewable |
TFTR. bors r=bdarnell |
26335: roachpb: introduce QueryIntent request r=bdarnell a=nvanbenschoten This change introduces a new request method called QueryIntent. The request type draws parallels to the QueryTxn method, but it visits an intent instead of a transaction record and returns whether the intent exists or not. The request type also includes an "if missing" behavior, which allows clients to optionally ensure that the request prevents a missing intent from ever being written or return an error if the intent is found to be missing. This request type was proposed/discussed in both #24194 and #16026. It is a prerequisite for either proposal. Release note: None Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Build succeeded |
This change introduces a new request method called QueryIntent. The request
type draws parallels to the QueryTxn method, but it visits an intent instead
of a transaction record and returns whether the intent exists or not. The
request type also includes an "if missing" behavior, which allows clients
to optionally ensure that the request prevents a missing intent from ever
being written or return an error if the intent is found to be missing.
This request type was proposed/discussed in both #24194 and #16026. It is a
prerequisite for either proposal.
Release note: None