-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
intentresolver: misc cleanups #53105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup.
Reviewed 1 of 1 files at r1, 5 of 5 files at r2, 1 of 1 files at r3, 4 of 4 files at r4, 1 of 1 files at r5, 7 of 7 files at r6.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @andreimatei)
pkg/kv/kvserver/concurrency/lock_table_waiter.go, line 128 at r2 (raw file):
// ResolveIntent synchronously resolves the provided intent. ResolveIntent(context.Context, roachpb.LockUpdate, intentresolver.ResolveOptions) *Error
👎 to this second commit. I wouldn't make it unless we need to, and the commit message is not very convincing. The entire concurrency
package works on *roachpb.Error
because it's awkward everywhere that we mix them (as you're noticing). I wouldn't make this change unless you're committed to switching the concurrency package and the txnwait
package over to error
s as well. Otherwise, we're just shifting ugly code around for no actual benefit.
pkg/kv/kvserver/intentresolver/intent_resolver.go, line 774 at r3 (raw file):
// ResolveOptions is used during intent resolution. type ResolveOptions struct { // If set, the ranges containing the intents are to be poisoned.
Is there a good explanation of "poisoning a range" anywhere? Is so, could you reference that here? If not, is this a good place for one?
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 925 at r5 (raw file):
func respForResolveIntentBatch( t *testing.T, ba roachpb.BatchRequest, checkTxnStatusOpt checkTxnStatusOpt,
Would it make more sense to just specify the status that we expect the intents to have? Is that possible?
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 227 at r6 (raw file):
close(done) } txn := c.txn
Do we want to clone this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @nvanbenschoten)
pkg/kv/kvserver/concurrency/lock_table_waiter.go, line 128 at r2 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
👎 to this second commit. I wouldn't make it unless we need to, and the commit message is not very convincing. The entire
concurrency
package works on*roachpb.Error
because it's awkward everywhere that we mix them (as you're noticing). I wouldn't make this change unless you're committed to switching the concurrency package and thetxnwait
package over toerror
s as well. Otherwise, we're just shifting ugly code around for no actual benefit.
The reason I've done it is because I'll be adding ResolveIntent
to the rangefeed.TxnPusher
iface, to replace CleanupTxnIntentsAsync
. CleanupTxnIntentsAsync
already returns error, and I don't want to move the rangefeed
package backwards.
Does that change your mind?
I wouldn't have gone ahead to do this change if it wasn't for the future plans, but generally, to me, moving from pErr->err when possible is almost always good. Even if a package deals with pErr a lot, it also probably also deals with err a lot anyway. The awkwardness to transforms err->pErr is lower than the other way, at least to me. In this particular case, the commit results in a net -2 calls to roachpb.NewError()
and -1 .GoError()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @andreimatei)
pkg/kv/kvserver/concurrency/lock_table_waiter.go, line 128 at r2 (raw file):
I don't want to move the rangefeed package backwards.
Agreed, this is definitely not something we want to do.
But you're not going to be adding ResolveIntents
to the interface directly, right? You're going to be calling into the IntentResolver
from rangefeedTxnPusher
. So you can perform the .GoError()
there and not leak anything into the rangefeed
package.
The way I see it, if you make this change then we now have one more package that's mixing pErr
and err
.
1c62fa6
to
4172f88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/kv/kvserver/concurrency/lock_table_waiter.go, line 128 at r2 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
I don't want to move the rangefeed package backwards.
Agreed, this is definitely not something we want to do.
But you're not going to be adding
ResolveIntents
to the interface directly, right? You're going to be calling into theIntentResolver
fromrangefeedTxnPusher
. So you can perform the.GoError()
there and not leak anything into therangefeed
package.The way I see it, if you make this change then we now have one more package that's mixing
pErr
anderr
.
removed the commit, under protest
pkg/kv/kvserver/intentresolver/intent_resolver.go, line 774 at r3 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Is there a good explanation of "poisoning a range" anywhere? Is so, could you reference that here? If not, is this a good place for one?
added a comment
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 925 at r5 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Would it make more sense to just specify the status that we expect the intents to have? Is that possible?
done, see now
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 227 at r6 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Do we want to clone this?
it wasn't technically generally since we overwrite the LockSpans slice below every time, but yeah I've added a clone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r8, 2 of 4 files at r9, 7 of 7 files at r11.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 851 at r11 (raw file):
checkTxnAborted checkTxnStatusOpt = true // NOTE: There shouldbe a checkTxnCommitted option, but no test currently uses
should be
4172f88
to
e8ecad7
Compare
Release note: None
The comment was referring to some waiting option that's no longer present. Release note: None
That function took (txn, spans), but it was always called with (txn, txn.LockSpans). I made it a method on the txn. Release note: None
This patch improves TestCleanupTxnIntentsOnGCAsync, making it check that the intents that get cleaned up get cleaned with a finalized status. Without this, the test would pass if the ResolveIntent requests resulting from GC after successful PUSH_ABORTS were not sent with the PENDING instead of ABORTED status. Release note: None
e8ecad7
to
49dad4f
Compare
Before this patch, IntentResolver.CleanupTxnIntentsOnGCAsync() was taking both a transaction and an []LockUpdate. This was confusing, because each LockUpdate also has a TxnMeta in it. The implementation was also surprising to me, since the method pushes the txn and then updates the intents with the results of the push one by one. The method was always called with a txn and all its intents; I don't think it would make sense any other way. So this patch simplifies the interface: the method now only takes a txn and then reads the intents from it. Release note: None
49dad4f
to
75dbf3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @nvanbenschoten)
pkg/kv/kvserver/intentresolver/intent_resolver_test.go, line 851 at r11 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
should be
done
Build succeeded: |
See individual commits.