Skip to content
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

ui, server: modify hot ranges api and table to use new contents approx. #134106

Conversation

angles-n-daemons
Copy link
Contributor

@angles-n-daemons angles-n-daemons commented Nov 1, 2024

ui, server: modify hot ranges api and table to use new contents approx.

This change is the last in a set of commits to change the hot ranges
page from only showing one table, index per range to many. It builds on
top of the changes in the catalog reader
(10b9ee0) and the range utilities
(109219d) to surface a set of tables,
indexes for each range.

The primary changes in this commit specifically are the modification of
the status server to use the new rangeutil utilities, and changing the
wire, presentation format of the information.

image

Epic: CRDB-43151
Fixes: #130997

Release note: changes the table, index contents of the hot ranges page in DB console.

@angles-n-daemons angles-n-daemons requested review from a team as code owners November 1, 2024 20:34
@angles-n-daemons angles-n-daemons requested review from kyle-a-wong and removed request for a team November 1, 2024 20:34
Copy link

blathers-crl bot commented Nov 1, 2024

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch 4 times, most recently from 9e652d9 to 1f6537a Compare November 5, 2024 14:54
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we rename to index_names.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

type IndexNamesList []IndexNames

// ToOutput is a simple function which returns a set of de-duplicated,
// fully referenced database, table, and index names depending on the,
Copy link
Member

Choose a reason for hiding this comment

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

nit: extra comma end of line

Copy link
Member

Choose a reason for hiding this comment

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

Would it be useful at all to return these values sorted?

Copy link
Contributor Author

@angles-n-daemons angles-n-daemons Nov 5, 2024

Choose a reason for hiding this comment

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

Right now they will be sorted, but by how they appear in the range. Would sorting them by name look cleaner?

for _, idx := range idxl {
table := idx.Table
if multipleDatabases {
table = idx.Database + "." + table
Copy link
Member

Choose a reason for hiding this comment

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

Are these strings quoted? Will we have any issues with db names and tables with . in them?
E.g. database my.db has table table and databas my has table db.table. Is it important that this output differentiates those?

Copy link
Contributor Author

@angles-n-daemons angles-n-daemons Nov 5, 2024

Choose a reason for hiding this comment

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

Have we run into this issue before? It can't hurt to quote them I suppose, though if it's not necessary I'd prefer against it.

Actually, I think this makes sense, I've added quotes if the name contains a ..

return idx.Database == other.Database &&
idx.Table == other.Table &&
idx.Index == other.Index
// a poor boy wants for a range slice
Copy link
Member

Choose a reason for hiding this comment

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

🤔 🍞

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: please merge this asap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh whoops, i'll remove this.

@@ -44,6 +44,19 @@ interface HotRangesTableProps {
onSortChange?: (ss: SortSetting) => void;
}

const tableToCell = (val: any) => {
// make an assumption if we see a single table
Copy link
Member

Choose a reason for hiding this comment

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

nit: clean up comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this function since the link isn't quite possible right now.

// make an assumption if we see a single table
if (val.tables.length === 1) {
return (
<Link to={util.EncodeDatabaseTableUri(val.databases[0], val.tables[0])}>
Copy link
Member

Choose a reason for hiding this comment

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

This link looks like it's to the legacy page. For the new pages we use the table id. I guess that might make it difficult to perform this linking since the hot ranges don't seem to return any ids.

Copy link
Contributor Author

@angles-n-daemons angles-n-daemons Nov 5, 2024

Choose a reason for hiding this comment

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

Gotcha, I'll see if there's a way to link it to the new databases page if possible

Ah I see, let me check with Kevin on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checked in, it's okay for the link to be omitted as part of this release.

@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch 3 times, most recently from e75ce34 to bd14e3f Compare November 6, 2024 17:14
Previously each range correlated to a single table, or even a single
index in a database, so all that was required to identify which tables,
indexes were in the range were to look at the start key of the range and
map it accordingly.

With range coalescing however, it's possible for one, or many, tables,
indexes and the like to reside within the same range. To properly
identify the contents of a range, this PR adds the following utilities:

 1. A utility function which turns a range into a span, and clamps it
		to its tenant's table space.
 2. A utility function which takes the above spans and uses the catalog
		and new descriptor by span utility to turn those spans into a set of
		table descriptors ordered by id.
 3. A utility function which transforms those table descriptors into a
		set of (database, table, index) names which deduplicate and identify
		each index uniquely.
 4. A utility function, which merges the ranges and indexes into a map
		keyed by RangeID whose values are the above index names.
 5. A primary entrypoint for consumers from which a set of ranges can be
		passed in and a mapping from those ranges to indexes can be
		returned.

A variety of cavets come with this approach. It attempts to scan the
desciptors all at once, but it still will scan a sizable portion of the
descriptors table if the request is large enough. This makes no attempt
to describe system information which does not have a descriptor. It will
describe system tables which appear in the descriptors table, but it
will not try to explain "tables" which do not have descriptors (example
tsdb), or any other information stored in the keyspace without a
descriptor (PseudoTableIDs, GossipKeys for example).

Throughout this work, many existing utilities were duplicated, and then
un-duplicated (`keys.TableDataMin`, `roachpb.Span.Overlap`, etc). If you
see anything that seems to already exist, feel free to point it out
accordingly.

Epic: none
Fixes: cockroachdb#130997

Release note: None
@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch 2 times, most recently from b438b07 to 3d38295 Compare November 8, 2024 19:28
Copy link
Contributor

@kyle-a-wong kyle-a-wong left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angles-n-daemons, @lassenordahl, and @xinhaoz)


pkg/roachpb/data.go line 227 at r6 (raw file):

// Clamp fixes the key to something within the range a < k < b.
func (k Key) Clamp(a, b Key) Key {

nit:Can we rename these to min and max? Also do you think we should add validation / enforce that min is <= max?

Suggestion:

min, max Key

pkg/server/apiutil/rangeutil.go line 54 at r6 (raw file):

// GetRangeIndexMappings translates a set of ordered ranges into a
// RangeID -> []IndexNames mapping. It does this by executing the fololowing steps:

nit:sp

Suggestion:

following

pkg/server/apiutil/rangeutil.go line 119 at r6 (raw file):

}

// RangeToTableSpans is a simple utility function which converts a set of ranges

nit: rm


pkg/server/apiutil/rangeutil.go line 162 at r6 (raw file):

}

// TableDescriptorsToIndexNames is a simple function which maps a set of descriptors to the

nit: rm


pkg/server/apiutil/index_names.go line 34 at r9 (raw file):

// toFourPartIdentifier adds quotes to an identifier if it contains
// the four part delimiter '.'.
func toFourPartIdentifier(identifier string) string {

nit: I feel like it would be better to name this "maybeQuoteIdentifier" or something closer to what the function is doing

Code quote:

toFourPartIdentifier

pkg/server/apiutil/index_names.go line 36 at r9 (raw file):

func toFourPartIdentifier(identifier string) string {
	if strings.Contains(identifier, ".") {
		return "\"" + identifier + "\""

super nit: i find it more readable to use back tickets if i want to include "

Suggestion:

return `"` + identifier + `"`

pkg/sql/catalog/descs/collection.go line 1152 at r6 (raw file):

}

// but as a map with the database ID as the key.

I think this should be with the comment of the previous function, and this function needs its old docstring

Code quote:

// but as a map with the database ID as the key.

Copy link
Contributor Author

@angles-n-daemons angles-n-daemons left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @kyle-a-wong, @lassenordahl, and @xinhaoz)


pkg/roachpb/data.go line 227 at r6 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

nit:Can we rename these to min and max? Also do you think we should add validation / enforce that min is <= max?

done, agreed on validation, added an error on the signature.


pkg/server/apiutil/index_names.go line 34 at r9 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

nit: I feel like it would be better to name this "maybeQuoteIdentifier" or something closer to what the function is doing

Kind of, though I think why the quote is being added is important. How do you feel about quoteIfContainsDot?


pkg/server/apiutil/index_names.go line 36 at r9 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

super nit: i find it more readable to use back tickets if i want to include "

agreed, added.


pkg/server/apiutil/rangeutil.go line 54 at r6 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

nit:sp

👀 fixed.


pkg/server/apiutil/rangeutil.go line 119 at r6 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

nit: rm

done.


pkg/server/apiutil/rangeutil.go line 162 at r6 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

nit: rm

done.


pkg/sql/catalog/descs/collection.go line 1152 at r6 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

I think this should be with the comment of the previous function, and this function needs its old docstring

ah nice catch, fixed.

@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch from 3d38295 to feae548 Compare November 11, 2024 19:08
Copy link
Contributor

@kyle-a-wong kyle-a-wong left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angles-n-daemons, @lassenordahl, and @xinhaoz)


pkg/server/apiutil/index_names.go line 34 at r9 (raw file):

Previously, angles-n-daemons (Brian Dillmann) wrote…

Kind of, though I think why the quote is being added is important. How do you feel about quoteIfContainsDot?

yeah quoteIfContainsDot is fine with me

@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch from feae548 to 91608ef Compare November 11, 2024 22:18
@angles-n-daemons
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request Nov 11, 2024
134106: ui, server: modify hot ranges api and table to use new contents approx. r=angles-n-daemons a=angles-n-daemons

ui, server: modify hot ranges api and table to use new contents approx.

This change is the last in a set of commits to change the hot ranges
page from only showing one table, index per range to many. It builds on
top of the changes in the catalog reader
(10b9ee0) and the range utilities
(109219d) to surface a set of tables,
indexes for each range.

The primary changes in this commit specifically are the modification of
the status server to use the new `rangeutil` utilities, and changing the
wire, presentation format of the information.

![image](https://github.com/user-attachments/assets/c5e0a175-7940-4051-b4de-c9ba9c492951)

Epic: CRDB-43151
Fixes: #130997

Release note: changes the table, index contents of the hot ranges page in DB console.


134868: licenses: remove unneeded notice file r=rail a=jlinder

Part of CRDB-43871

Release note: None

Co-authored-by: Brian Dillmann <brian.dillmann@cockroachlabs.com>
Co-authored-by: James H. Linder <jamesl@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Nov 11, 2024

Build failed (retrying...):

craig bot pushed a commit that referenced this pull request Nov 11, 2024
134106: ui, server: modify hot ranges api and table to use new contents approx. r=angles-n-daemons a=angles-n-daemons

ui, server: modify hot ranges api and table to use new contents approx.

This change is the last in a set of commits to change the hot ranges
page from only showing one table, index per range to many. It builds on
top of the changes in the catalog reader
(10b9ee0) and the range utilities
(109219d) to surface a set of tables,
indexes for each range.

The primary changes in this commit specifically are the modification of
the status server to use the new `rangeutil` utilities, and changing the
wire, presentation format of the information.

![image](https://github.com/user-attachments/assets/c5e0a175-7940-4051-b4de-c9ba9c492951)

Epic: CRDB-43151
Fixes: #130997

Release note: changes the table, index contents of the hot ranges page in DB console.


134597: vecstore: add the vecstore package r=mw5h a=andy-kimball

The vecstore package defines a Store interface that abstracts away the interactions that a vector index has with the component storing the vectors. This PR contains a simple implementation of Store that stores the vectors in memory. In the future, we'll have an implementation that stores the vectors in CRDB. The Store interface supports batching of important operations like Search so that in the future we can push such operations closer to the data. In addition, Store methods take a transaction so that the vector index can perform complex multi-step operations like split or merge with transactional guarantees.

Epic: CRDB-42943

Release note: None

Co-authored-by: Brian Dillmann <brian.dillmann@cockroachlabs.com>
Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Nov 11, 2024

Build failed (retrying...):

craig bot pushed a commit that referenced this pull request Nov 11, 2024
134106: ui, server: modify hot ranges api and table to use new contents approx. r=angles-n-daemons a=angles-n-daemons

ui, server: modify hot ranges api and table to use new contents approx.

This change is the last in a set of commits to change the hot ranges
page from only showing one table, index per range to many. It builds on
top of the changes in the catalog reader
(10b9ee0) and the range utilities
(109219d) to surface a set of tables,
indexes for each range.

The primary changes in this commit specifically are the modification of
the status server to use the new `rangeutil` utilities, and changing the
wire, presentation format of the information.

![image](https://github.com/user-attachments/assets/c5e0a175-7940-4051-b4de-c9ba9c492951)

Epic: CRDB-43151
Fixes: #130997

Release note: changes the table, index contents of the hot ranges page in DB console.


Co-authored-by: Brian Dillmann <brian.dillmann@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Nov 12, 2024

Build failed:

This change is the last in a set of commits to change the hot ranges
page from only showing one table, index per range to many. It builds on
top of the changes in the catalog reader
(10b9ee0) and the range utilities
(109219d) to surface a set of tables,
indexes for each range.

The primary changes in this commit specifically are the modification of
the status server to use the new `rangeutil` utilities, and changing the
wire, presentation format of the information.

Epic: CRDB-43151
Fixes: cockroachdb#130997

Release note (bug fix): changes the table, index contents of the hot ranges page
in DB console.
@angles-n-daemons angles-n-daemons force-pushed the use-new-range-index-finding-mechanisms branch from 91608ef to a609fd6 Compare November 12, 2024 15:18
@angles-n-daemons
Copy link
Contributor Author

bors r+

@craig craig bot merged commit deb2445 into cockroachdb:master Nov 12, 2024
22 of 23 checks passed
@angles-n-daemons angles-n-daemons deleted the use-new-range-index-finding-mechanisms branch November 12, 2024 18:21
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.

List multiple table names in the Hot Ranges table for coalesced ranges containing different tables
5 participants