-
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
distsql: introduce SpanResolver #10575
distsql: introduce SpanResolver #10575
Conversation
still working on more tests Review status: 0 of 18 files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
05c068c
to
a79c535
Compare
Thanks a lot for getting this done!! WOOOHOO Most comments I have are from the perspective of a prospective user. Someone more familiar with the lower layers that we're using should also take a look Review status: 0 of 18 files reviewed at latest revision, 14 unresolved discussions, some commit checks failed. pkg/sql/distsql/span_resolver.go, line 74 at r2 (raw file):
Can't we use an existing type for this (like encoding.Direction)? Or if the direction is actually not important and we only care about which end is inclusive, maybe name them accordingly (eg StartInclusive, EndInclusive) pkg/sql/distsql/span_resolver.go, line 93 at r2 (raw file):
duplicate comment pkg/sql/distsql/span_resolver.go, line 108 at r2 (raw file):
could use a comment pkg/sql/distsql/span_resolver.go, line 132 at r2 (raw file):
can/should we reuse the iterator? it may make sense to continue seeking from where we left off pkg/sql/distsql/span_resolver.go, line 160 at r2 (raw file):
If pkg/sql/distsql/span_resolver.go, line 166 at r2 (raw file):
What is not ideal here is that if we have a lot of spans within a replica, we have a separate copy of the same ReplicaInfo for each span. I'm thinking that perhaps in the future we will want have a route-by-range that uses this API with a lot of small spans (rows). The calling code will have to go through all the spans and do some work to trim the spans to the range boundaries, so it could just as easily handle a pkg/sql/distsql/span_resolver.go, line 169 at r2 (raw file):
Is it guaranteed that the ranges for each span cover the span without gaps? (is the end key of each range the same with the start key of the next?) pkg/sql/distsql/span_resolver.go, line 177 at r2 (raw file):
should we verify the sort order and error out or panic, in case the higher layers are doing something wrong? pkg/sql/distsql/span_resolver.go, line 206 at r2 (raw file):
we could have a single loop pkg/sql/distsql/span_resolver.go, line 208 at r2 (raw file):
We could check if the span is already completely inside the last pkg/sql/distsql/span_resolver.go, line 233 at r2 (raw file):
Maybe rangesPerLeaseHolder belongs in a separate struct where we explain that it contains stuff that oracle implementations can use to make their decisions. It would make it cleaner and easier to add more stuff. Also, why pkg/sql/distsql/span_resolver.go, line 298 at r2 (raw file):
[nit] extra line pkg/sql/distsql/span_resolver_test.go, line 199 at r2 (raw file):
We already have SQL for this, why not use that? pkg/sql/distsql/span_resolver_test.go, line 220 at r2 (raw file):
note that in the implementation of SPLIT AT, we had to tolerate occasional Comments from Reviewable |
a79c535
to
cd5baa7
Compare
Transformed the code into an iterator, see if you like it. I think it works more naturally with the lower layer, that's also an iterator, and it makes more clear the significance of that "scan direction" argument, and also makes it more natural for a client to mix directions between spans... Plus I also think we'll need to use an iteration model for Review status: 0 of 19 files reviewed at latest revision, 14 unresolved discussions, some commit checks failed. pkg/sql/distsql/span_resolver.go, line 74 at r2 (raw file):
|
But also get a review from someone with deeper `kv` knowledge, maybe @petermattis
Review status: 0 of 19 files reviewed at latest revision, 15 unresolved discussions, some commit checks failed. pkg/sql/distsql/span_resolver.go, line 74 at r2 (raw file):
|
cd5baa7
to
9450742
Compare
A few changes:
@RaduBerinde, I've kept the resolving of nodes to addresses inside the iterator, even though it could be done outside and only once per node. This is because, when an oracle is involved, we need to resolve through gossip to get the node attributes. And also because we avoid returning replicas on nodes that are not available in gossip. In any case, hopefully this isn't expensive. If it is, the DistSender has the same problem and we can likely improve the gossip lookup process. Review status: 0 of 21 files reviewed at latest revision, 15 unresolved discussions, some commit checks failed. pkg/sql/distsql/span_resolver.go, line 93 at r2 (raw file):
|
9450742
to
107b0b7
Compare
Review status: 0 of 21 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed. pkg/sql/index_selection.go, line 950 at r5 (raw file):
returns pkg/sql/distsql/span_resolver_test.go, line 450 at r5 (raw file):
If we exit the loop because Comments from Reviewable |
Reviewed 6 of 9 files at r1, 3 of 13 files at r4, 12 of 12 files at r5. pkg/sql/distsql/span_resolver.go, line 35 at r5 (raw file):
Once we have epoch-based leases, it will be rare for a range to not have an active lease. pkg/sql/distsql/span_resolver.go, line 82 at r5 (raw file):
Not currently, and there are other places where we store copies of the NodeDescriptor so we'd have to clean all of those up before we could allow runtime changes to the descriptor. Unlikely to happen any time soon. pkg/sql/distsql/span_resolver.go, line 304 at r5 (raw file):
This method seems misnamed. These aren't really trying to guess where the lease holder is, they're choosing where we would prefer the lease go if it's free. pkg/sql/sqlbase/errors.go, line 427 at r5 (raw file):
s/database/range/ pkg/sql/sqlbase/errors.go, line 435 at r5 (raw file):
I know you're just following the pattern in this file, but it's unusual for the constructor name and the type name to differ. Most of our error types use the suffix pkg/testutils/testcluster/testcluster.go, line 248 at r5 (raw file):
Merge conflict warning: I think @vivekmenezes will need to change this method in #10728. Comments from Reviewable |
Unfortunately the tests were flaky because of #10751, whose investigation showed a number of weird things in how we manage the Review status: all files reviewed at latest revision, 10 unresolved discussions, some commit checks failed. pkg/sql/index_selection.go, line 950 at r5 (raw file):
|
107b0b7
to
b4979df
Compare
Review status: 4 of 21 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. pkg/sql/distsql/span_resolver.go, line 304 at r5 (raw file):
|
b4979df
to
f1e1773
Compare
Review status: 3 of 20 files reviewed at latest revision, 9 unresolved discussions. pkg/sql/distsql/span_resolver.go, line 304 at r5 (raw file): Previously, bdarnell (Ben Darnell) wrote…> Where is it guessing? I'd suggest something like ChoosePreferredLeaseHolder for the name.pkg/sql/distsql/span_resolver_test.go, line 220 at r7 (raw file): Previously, bdarnell (Ben Darnell) wrote…> s/rage/race/pkg/testutils/testcluster/testcluster.go, line 248 at r5 (raw file): Previously, bdarnell (Ben Darnell) wrote…> I'm arguing there that the callers of AdminSplit should be responsible for retrying instead of the lower levels.Comments from Reviewable |
... from TestCluster, so that they can be used by tests that only need a single node. Also change their results from pointers to vals.
SpanResolver will be used by physical planning for figuring out the mapping between key spans and kv ranges.
f1e1773
to
d399ef1
Compare
🎉 |
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)