Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
131757: roachtest: fix pg_regress r=rytaft a=rytaft

Fixes #130735

Release note: None

131774: cluster-ui: populate db name in db details page r=xinhaoz a=xinhaoz

This commit populates the db name as the page title
in the v2 db details page as well as breadcrumb navigation
back to the db list page. To do so we all the get db metadata
by id api on the details page.


Epic: CRDB-37558
Fixes: #131119

Release note: None

131787: roachtest: fix rebalance/by-load/*/mixed-version shared process tests r=stevendanna,tbg a=kvoli

In #129117, `rebalance/by-load/*/mixed-version` roachtest had
shared-process multi-tenancy introduced, which would occasionally cause
these tests to fail erroneously.

The cause of all the failures was identical, CPU utilization of some
nodes which couldn't have been possible, > 100%, e.g.,

```
CPU not evenly balanced after timeout: outside bounds mean=102.5 tolerance=20.0% (±20.5) bounds=[82.0, 123.0]
below  = [s3: 81 (-20.7%), s5: 65 (-36.5%)]
within = [s2: 116 (+14.0%), s4: 92 (-9.7%), s6: 88 (-13.2%)]
above  = [s1: 170 (+66.1%)]
```

As the query would aggregate every tenant's timeseries data on a given
node, instead of only the system tenant.

Update the timeseries utility used to query the CPU to also take in a
`TenantID` parameter, which is then used to query only the system
tenant.

Fixes: #129962
Fixes: #131274
Fixes: #129464
Release note: None

131832: kvserver: fix dropped raft heartbeats in test helper r=kvoli a=pav-kv

The `unreliableRaftHandlerFuncs` type drops messages by default, if the corresponding "drop" function is nil.

The `enableVerboseRaftMsgLoggingForRange` is meant to add a no-op interceptor of all raft messages, but because of a bug it ended up dropping heartbeat responses. This caused lack of `MsgApp` stream liveness from leader to followers, and a perpetual `StateProbe`.

Fixes #131735

Co-authored-by: Rebecca Taft <[email protected]>
Co-authored-by: Xin Hao Zhang <[email protected]>
Co-authored-by: Austen McClernon <[email protected]>
Co-authored-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
5 people committed Oct 3, 2024
5 parents a11cea6 + 1432b06 + 5a4a582 + a7cc9e9 + f775825 commit 6a3db0e
Show file tree
Hide file tree
Showing 7 changed files with 4,416 additions and 4,409 deletions.
8,737 changes: 4,338 additions & 4,399 deletions pkg/cmd/roachtest/testdata/regression.diffs

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions pkg/cmd/roachtest/tests/rebalance_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/mixedversion"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm"
Expand Down Expand Up @@ -343,6 +344,7 @@ func makeStoreCPUFn(
name: "cr.node.sys.cpu.combined.percent-normalized",
queryType: total,
sources: []string{fmt.Sprintf("%d", i+1)},
tenantID: roachpb.SystemTenantID,
}
}

Expand All @@ -367,6 +369,14 @@ func makeStoreCPUFn(
}
// Take the latest CPU data point only.
cpu := result.Datapoints[len(result.Datapoints)-1].Value
// The datapoint is a float representing a percentage in [0,1.0]. Assert
// as much to avoid any surprises.
if cpu < 0 || cpu > 1 {
return nil, errors.Newf(
"node %d has core count normalized CPU utilization ts datapoint "+
"not in [0%,100%] (impossible!): %f [resp=%+v]", node, cpu, resp)
}

nodeIdx := node * storesPerNode
for storeOffset := 0; storeOffset < storesPerNode; storeOffset++ {
// The values will be a normalized float in [0,1.0], scale to a
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/roachtest/tests/ts_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
"github.com/cockroachdb/cockroach/pkg/ts/tspb"
)
Expand Down Expand Up @@ -40,6 +41,11 @@ type tsQuery struct {
name string
queryType tsQueryType
sources []string
// tenantID specifies which tenant to query metrics for. If uninitialized,
// the query will be for all tenants (default). Use roachpb.SystemTenantID as
// the value here to query just the system tenant metrics, in a multi-tenant
// cluster.
tenantID roachpb.TenantID
}

func mustGetMetrics(
Expand Down Expand Up @@ -110,6 +116,7 @@ func getMetricsWithSamplePeriod(
Downsampler: tspb.TimeSeriesQueryAggregator_AVG.Enum(),
SourceAggregator: tspb.TimeSeriesQueryAggregator_SUM.Enum(),
Sources: tsQueries[i].sources,
TenantID: tsQueries[i].tenantID,
}
case rate:
queries[i] = tspb.Query{
Expand All @@ -118,6 +125,7 @@ func getMetricsWithSamplePeriod(
SourceAggregator: tspb.TimeSeriesQueryAggregator_SUM.Enum(),
Derivative: tspb.TimeSeriesQueryDerivative_NON_NEGATIVE_DERIVATIVE.Enum(),
Sources: tsQueries[i].sources,
TenantID: tsQueries[i].tenantID,
}
default:
panic("unexpected")
Expand Down
7 changes: 1 addition & 6 deletions pkg/kv/kvserver/flow_control_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvflowcontrol"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvflowcontrol/kvflowinspectpb"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
Expand Down Expand Up @@ -4798,11 +4797,7 @@ func (h *flowControlTestHelper) enableVerboseRaftMsgLoggingForRange(rangeID roac
&unreliableRaftHandler{
rangeID: rangeID,
IncomingRaftMessageHandler: si,
unreliableRaftHandlerFuncs: unreliableRaftHandlerFuncs{
dropReq: func(req *kvserverpb.RaftMessageRequest) bool {
return false
},
},
unreliableRaftHandlerFuncs: noopRaftHandlerFuncs(),
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,30 @@ export const useDatabaseMetadata = (req: DatabaseMetadataRequest) => {
refreshDatabases: mutate,
};
};

type DatabaseMetadataByIDResponse = {
metadata: DatabaseMetadata;
};

const getDatabaseMetadataByID = async (
dbID: number,
): Promise<DatabaseMetadataByIDResponse> => {
return fetchDataJSON(DATABASES_API_V2 + dbID + "/");
};

export const useDatabaseMetadataByID = (dbID: number) => {
const { data, error, isLoading } = useSWR<DatabaseMetadataByIDResponse>(
["databaseMetadataByID", dbID],
() => getDatabaseMetadataByID(dbID),
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
},
);

return {
data,
error,
isLoading,
};
};
29 changes: 25 additions & 4 deletions pkg/ui/workspaces/cluster-ui/src/databaseDetailsV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.

import { Tabs } from "antd";
import { Skeleton, Tabs } from "antd";
import React from "react";
import { useHistory, useLocation } from "react-router";

import { useDatabaseMetadataByID } from "src/api/databases/getDatabaseMetadataApi";
import { commonStyles } from "src/common";
import { useRouteParams } from "src/hooks/useRouteParams";
import { PageLayout } from "src/layouts";
import { PageHeader } from "src/sharedFromCloud/pageHeader";
import { queryByName, tabAttr } from "src/util";

import { queryByName, tabAttr } from "../util";
import { DB_PAGE_PATH } from "../util/routes";

import { DbGrantsView } from "./dbGrantsView";
import { TablesPageV2 } from "./tablesView";
Expand All @@ -21,6 +24,9 @@ enum TabKeys {
GRANTS = "grants",
}
export const DatabaseDetailsPageV2 = () => {
const { dbID: dbIdRouteParam } = useRouteParams();
const dbId = parseInt(dbIdRouteParam, 10);
const { data, isLoading, error } = useDatabaseMetadataByID(dbId);
const history = useHistory();
const location = useLocation();
const tab = queryByName(location, tabAttr) ?? TabKeys.TABLES;
Expand All @@ -38,7 +44,6 @@ export const DatabaseDetailsPageV2 = () => {
});
};

// TODO (xinhaoz) #131119 - Populate db name here.
const tabItems = [
{
key: TabKeys.TABLES,
Expand All @@ -52,9 +57,25 @@ export const DatabaseDetailsPageV2 = () => {
},
];

const dbName =
error?.status === 404 || !data
? "Database Not Found"
: data.metadata.db_name;

const breadCrumbItems = [
{ name: "Databases", link: DB_PAGE_PATH },
{
name: dbName,
link: null,
},
];

return (
<PageLayout>
<PageHeader title="myDB" />
<PageHeader
breadcrumbItems={breadCrumbItems}
title={<Skeleton loading={isLoading}>{dbName}</Skeleton>}
/>
<Tabs
defaultActiveKey={TabKeys.TABLES}
className={commonStyles("cockroach--tabs")}
Expand Down
7 changes: 7 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/util/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2024 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.

export const DB_PAGE_PATH = "/databases";
export const databaseDetailsPagePath = (dbId: number) => `/databases/${dbId}`;

0 comments on commit 6a3db0e

Please sign in to comment.