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, db-console: fix bug where store ids are treated as node ids #119260

Merged
merged 1 commit into from Mar 11, 2024

Conversation

laurenbarker
Copy link
Contributor

Previously, store ids were being treated as node ids on the databases view. This resulted in "Regions/Nodes" column showing inaccurate information in some cases. Now, store ids are mapped to node ids on the databases view which resolves the issue.

Fixes: #118957

Release note (ui change): Resolves an issue where clusters with multiple stores per node may list inaccurate region/node information in the databases table.

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Feb 15, 2024

CLA assistant check
All committers have signed the CLA.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@laurenbarker laurenbarker force-pushed the store-ids branch 2 times, most recently from fb82441 to b83f754 Compare February 15, 2024 20:50
@@ -147,7 +160,7 @@ const deriveDatabaseTableDetails = (
const normalizedPrivileges = normalizePrivileges(
[].concat(...grants.map(grant => grant.privileges)),
);
const nodes = results?.stats.replicaData.nodeIDs || [];
const nodes: Nodes = { kind: "node", ids: results?.stats.replicaData.nodeIDs || [] };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The table views appear to already be using node IDs. Please correct me if I'm reading this incorrectly.

// regionA(n1, n2), regionB(n2,n3), ...
/** Store ids and node ids are both of type `number[]`. To disambiguate, a
* `kind` field is included in the type. */
export type Stores = { kind: "store", ids: number[] };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expanding the type is the only way I could think to disambiguate the data of type number[]... Open to alternatives here.

@@ -102,7 +142,7 @@ export function nodesByRegionMapToString(
.join(", ");
}

export function createNodesByRegionMap(
function createNodesByRegionMap(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nodesByRegionMapToString and createNodesByRegionMap are only used in this file, so I removed the exports.

@laurenbarker laurenbarker marked this pull request as ready for review February 15, 2024 20:55
@laurenbarker laurenbarker requested a review from a team as a code owner February 15, 2024 20:55
@laurenbarker laurenbarker requested review from xinhaoz and removed request for a team February 15, 2024 20:55
@laurenbarker laurenbarker force-pushed the store-ids branch 2 times, most recently from d74ad6f to 07922e8 Compare February 15, 2024 21:20
@laurenbarker
Copy link
Contributor Author

Looks like I need to stub an API response in pkg/ui/workspaces/db-console/src/views/databases/databasesPage/redux.spec.ts. I'll do that tomorrow.

@laurenbarker laurenbarker force-pushed the store-ids branch 3 times, most recently from 300f898 to f97384b Compare February 20, 2024 23:53
@laurenbarker
Copy link
Contributor Author

Rebased on changes from #118996 was merged.

@laurenbarker laurenbarker force-pushed the store-ids branch 2 times, most recently from 38b1347 to 68fe962 Compare February 21, 2024 17:26
@xinhaoz
Copy link
Member

xinhaoz commented Feb 21, 2024

pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 181 at r2 (raw file):

  );
  /** List of store IDs for the current cluster. All of the values in the
   * `*replicas` columns correspond to store IDs. */

nit: I think this comment can be deleted now since the field was renamed.

Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking this on (and taking the time to understand what's going on with db console as a whole :)), just some super small nits but otherwise all good 💯

Reviewed 3 of 7 files at r1, 7 of 9 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @laurenbarker)


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 163 at r1 (raw file):

Previously, laurenbarker (Lauren Barker) wrote…

The table views appear to already be using node IDs. Please correct me if I'm reading this incorrectly.

Yeah, I believe all the database page views assumed they were using node ids and store ids.


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 180 at r1 (raw file):

Previously, laurenbarker (Lauren Barker) wrote…

I'm assuming this should be node ids and not store ids too.

yup! 👍


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 241 at r2 (raw file):

    /** List of store IDs for the current cluster. All of the values in the
     * `*replicas` columns correspond to store IDs. */

same here with the comment


pkg/ui/workspaces/cluster-ui/src/databases/util.tsx line 145 at r1 (raw file):

Previously, laurenbarker (Lauren Barker) wrote…

nodesByRegionMapToString and createNodesByRegionMap are only used in this file, so I removed the exports.

thank you!


pkg/ui/workspaces/cluster-ui/src/databases/util.tsx line 71 at r2 (raw file):

 * @returns A list of node ids for the cluster.
 */
export function getNodeIdsFromStoreIds(

Can we just make this return the Nodes type directly since all its use cases seem to be creating Nodes?


pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx line 112 at r2 (raw file):

  nodes?: number[];
  /** A list of node statuses so that store ids can be mapped to nodes. */
  nodeStatuses: cockroach.server.status.statuspb.INodeStatus[];

I don't think we need to add this to the props.

@xinhaoz
Copy link
Member

xinhaoz commented Feb 21, 2024

pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 163 at r1 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

Yeah, I believe all the database page views assumed they were using node ids and store ids.

not store ids**

@laurenbarker laurenbarker force-pushed the store-ids branch 2 times, most recently from 9c24f4a to 3b6f013 Compare February 21, 2024 23:13
Copy link
Contributor Author

@laurenbarker laurenbarker left a comment

Choose a reason for hiding this comment

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

TFTR @xinhaoz! I think I need help with the last test -- "loads table data" in pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts. nodeStatuses is undefined and I'm not sure how to get that information populated in the store and if I need to modify non-test code as well.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 163 at r1 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

not store ids**

Oops, this was a comment from before you made your change. I wasn't sure if replicaData.nodeIDs were node ids or store ids. Turns out they were store ids and you updated the name 😄


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 181 at r2 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

nit: I think this comment can be deleted now since the field was renamed.

Good call. Done.


pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts line 241 at r2 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

same here with the comment

Done.


pkg/ui/workspaces/cluster-ui/src/databases/util.tsx line 71 at r2 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

Can we just make this return the Nodes type directly since all its use cases seem to be creating Nodes?

Oh yeah, let's do that!


pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx line 112 at r2 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

I don't think we need to add this to the props.

Oops, removed!

Previously, store ids were being treated as node ids on the databases
view. This resulted in "Regions/Nodes" column showing inaccurate
information in some cases. Now, store ids are mapped to node ids on the
databases view which resolves the issue.

Also, a log message is skipped during tests so that the output isn't
polluted with expected warnings.

Fixes: cockroachdb#118957

Release note (ui change): Resolves an issue where clusters with multiple
stores per node may list inaccurate region/node information in the
databases table.
@laurenbarker
Copy link
Contributor Author

@xinhaoz I think this is ready for another pass! (finally)

@laurenbarker
Copy link
Contributor Author

TFTRs @xinhaoz!

@laurenbarker
Copy link
Contributor Author

bors r+

@laurenbarker
Copy link
Contributor Author

blathers backport 23.2 23.1

Copy link

blathers-crl bot commented Mar 11, 2024

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from e3c09d0 to blathers/backport-release-23.1-119260: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1 failed. See errors above.


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

@craig
Copy link
Contributor

craig bot commented Mar 11, 2024

Build succeeded:

@craig craig bot merged commit 436fcd5 into cockroachdb:master Mar 11, 2024
17 of 18 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.

ui: db pages are using store ids as node ids for regions mapping
3 participants