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

cluster-ui: skip undefined regions on database pages #106778

Merged
merged 1 commit into from Jul 17, 2023

Conversation

THardy98
Copy link
Contributor

@THardy98 THardy98 commented Jul 13, 2023

Epic: None
Addresses: #106697

This patch skips undefined regions on the databases pages. The undefined behaviour occurs when we try to match a database's node IDs (i.e. the nodes with ranges that contain data belong to one of the database's tables) from the database details endpoint, to nodes' region information from the nodes endpoint.

The nodes endpoint is authoritative and is refreshed at a regular interval. However, the database details endpoint is only fetched once on page load, and it's node information comes from a cache, leading to the potential of stale data (this information is authoritative in 23.1, but not in 22.2).

Consequently when trying to match cached node IDs with recent node regions information, we can come across behaviour where we try to get region information for a node ID that is no longer valid (i.e. in the case of a decommissioned node), resulting in undefined and surfacing outdated node information.

This change ensures that when we encounter such occurrences, we avoid displaying them in the console.

Release note (bug fix): Avoid displaying undefined regions on the databases pages.

@THardy98 THardy98 requested a review from a team July 13, 2023 18:54
@THardy98 THardy98 requested a review from a team as a code owner July 13, 2023 18:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@THardy98 THardy98 removed the request for review from a team July 13, 2023 18:54
@@ -54,7 +54,7 @@ describe("Getting nodes by region string", () => {
const nodes = [1, 2, 3];
const regions = {};
const result = getNodesByRegionString(nodes, regions, false);
assert.deepStrictEqual(result, `undefined(n1,n2,n3)`);
assert.deepStrictEqual(result, "");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: prefer expect over assert

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.

@@ -99,6 +99,10 @@ export function createNodesByRegionMap(
): Record<string, number[]> {
const nodesByRegionMap: Record<string, number[]> = {};
nodes.forEach((node: number) => {
// If the node's region doesn't exist skip it.
if (nodeRegions[node.toString()] === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we specifically want to check for undefined or do we want to expand to a nullish check?

Copy link
Contributor

Choose a reason for hiding this comment

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

nullish check would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, done.

@THardy98 THardy98 force-pushed the skip_undefined_regions_master branch from bddfa32 to 2f4a43b Compare July 14, 2023 13:53
@THardy98 THardy98 requested a review from xinhaoz July 14, 2023 13:53
@THardy98 THardy98 force-pushed the skip_undefined_regions_master branch from 2f4a43b to ef5ebbd Compare July 14, 2023 15:02
This patch skips `undefined` regions on the databases pages. The
`undefined` behaviour occurs when we try to match a database's node IDs
(i.e. the nodes with ranges that contain data belong to one of the
database's tables) from the database details endpoint, to nodes' region
information from the nodes endpoint.

The nodes endpoint is authoritative and is refreshed at a regular
interval. However, the database details endpoint is only fetched once on
page load, and it's node information comes from a cache, leading to the
potential of stale data (this information is authoritative in 23.1, but
not in 22.2).

Consequently when trying to match cached node IDs with recent node
regions information, we can come across behaviour where we try to get
region information for a node ID that is no longer valid (i.e. in the
case of a decommissioned node), resulting in `undefined` and surfacing
outdated node information.

This change ensures that when we encounter such occurrences, we avoid
displaying them in the console.

Release note (bug fix): Avoid displaying `undefined` regions on the
databases pages.
@THardy98 THardy98 force-pushed the skip_undefined_regions_master branch from ef5ebbd to cba8f3e Compare July 14, 2023 19:40
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @xinhaoz)

@THardy98
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 17, 2023

Build succeeded:

@craig craig bot merged commit 26456a8 into cockroachdb:master Jul 17, 2023
7 checks passed
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.

None yet

4 participants