-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
ListAllTablets: improve efficiency within vitess and for caller #9560
Conversation
510838b
to
04703cb
Compare
4bf4702
to
9704252
Compare
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
c7d166f
to
dabb6e5
Compare
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
da8beca
to
ca568a1
Compare
FWIW, I did a quick/simple manual test with Consul too (using this code):
|
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.
Everything else looks good to me!
Thanks for the review, @GuptaManan100! I've addressed those things here: 648bb21 |
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.
Thankyou very much!
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.
A few comments/questions:
- The new function probably belongs more properly in directory.go than in file.go
- The current
ListDir
implementations seem to have some special logic (for locks/leases etc.). Is any of that relevant toList
? - In order for this new API to be generic, I believe we should also be returning the version for each object
- What happens if one of the children is a directory? What do we return for that object? I understand that files within that directory will be returned as well.
Why? This is a scan of keys based on the key prefix. These are K/V stores, the key is the full path. While they present a filesystem like interface, that is not what is there. There's no such thing as a "folder" or "directory" in a K/V store. In etcd, all of the data is in a single file called I apologize if you already know all this, but I think it might be helpful in this discussion.
ListDir simply returns the keys (not values) with a matching key prefix before the final / in the key. It does take a lock when generating that slice of matching keys:
So it locks the entire topo when generating that list of matching keys. It makes sense there as it's needed in order to generate that using a consistent read, because it's making N calls to the underlying topo implementation to build it. With List() there's a single call to the topo implementation and the consistent read is managed by the topo implementation itself. So I don't see the need here (and it's pretty heavy).
Can you explain why? For a list, I would think MVCC (view) version info is important and not a version of an individual record. The version is important when doing a read-update-write cycle. I'm not sure that would ever be used with List...
Again, there aren't directories or files. :-) |
@deepthi was kind enough to sit down with me one and one can chat about this, I wanted to summarize the discussion:
We're OK with the current location and name of the function. It may be a little awkward (as we're mapping several concepts), but it's not significantly more or less awkward than alternatives.
This was about what to do when the key represents a lock/lease, and in the case of
We both agreed on this. I will add another commit so that
This then maps to what
We agreed that this is not an issue. |
5ba21ff
to
5eb9123
Compare
@deepthi I modified the Thanks for the great suggestions! |
be26423
to
eeb4197
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.
Very nice. The implementation is very clean, and the test cases are good.
I like the way we fall back when List
is not provided by the underlying implementation.
Only one more thing to fix and then we can merge. I believe you need to run make vtadmin_web_proto_types
whenever changes are made to vtctldata.proto.
https://vitess.slack.com/archives/CMDJ2KFEZ/p1643297135016100
98c2950
to
04f712d
Compare
And add -keyspace and -tablet_type server side filters Signed-off-by: Matt Lord <[email protected]>
There's no clear need for it now that the topo server has the GetTabletsByCell() function, which is really what that topotools call did. Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
And SPARE tablet type to help And slight improvements after self review Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
This allows the caller to traverse the slice, knowing the key associated with the value, along with the version, and then decode the value (byte slice) into the expected type. Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
04f712d
to
6cafb22
Compare
These were added in vitessio/vitess#9560 Signed-off-by: Matt Lord <[email protected]>
Description
The
ListAllTablets
vtctl
command is one of the most widely used methods to observe the state of a Vitess cluster. Previously this code path would query the topo server for every tablet and if you had many things using this command simultaneously, and you had many hundreds or even thousands of tablets, you could begin to overwhelmvtctld
and the topo server with client server requests. This call also produced many rows of free form text that can be expensive to filter on the caller side and cause issues within the monitoring/alerting and automation related systems leveraging this command.Within Vitess
This work makes a single call to the topo server — for the topo implementations that support scans using a key prefix (etcd, consul, and k8s) — from
vtctld
to get the information on all tablets in a cell. So we go from 1 topo request per tablet to one topo request per cell.You can see this demonstrated here (->> click to expand):
The test:
The previous results:
The new results on this branch:
For the caller
This work adds support for server side filtering on the following common parameters (filtering by cell(s) already existed):
This can eliminate a lot of work on the caller side to filter out the full list of tablets.
You can see this demonstrated here (->> click to expand):
Related Issue(s)
Fixes: #9384
Checklist