Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
97306: kvserver: add storage.keys.tombstone.count metric r=nicktrav a=jbowens

Expose the number of tombstones in the storage engine as a timeseries metric. This provides some additional visibility into garbage collection and would help in diagnosing issues like cockroachlabs/support#2084.

Epic: None
Release note (ops change): Adds a new timeseries metric `storage.keys.tombstone.count` that shows the current count of point and range deletion tombstones across the storage engine.

97309: ui: fixed insights table bug on insights r=ericharmeling a=ericharmeling

cockroachdb#96440 introduced a bug to the Insights Table on the Schema
Insights page. This commit fixes that bug.

Loom: https://www.loom.com/share/0f81bc55371f49418f7f0175bbc5dff4

Release note: None
Epic: None

Co-authored-by: Jackson Owens <jackson@cockroachlabs.com>
Co-authored-by: Eric Harmeling <eric.harmeling@cockroachlabs.com>
  • Loading branch information
3 people committed Feb 21, 2023
3 parents 31b610b + 6dd2362 + 868b3ce commit 4806560
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
9 changes: 9 additions & 0 deletions pkg/kv/kvserver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ var (
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaRdbKeysTombstones = metric.Metadata{
Name: "storage.keys.tombstone.count",
Help: "Approximate count of DEL, SINGLEDEL and RANGEDEL internal keys across the storage engine.",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
// NB: bytes only ever get flushed into L0, so this metric does not
// exist for any other level.
metaRdbL0BytesFlushed = storageLevelMetricMetadata(
Expand Down Expand Up @@ -1811,6 +1817,7 @@ type StoreMetrics struct {
RdbPendingCompaction *metric.Gauge
RdbMarkedForCompactionFiles *metric.Gauge
RdbKeysRangeKeySets *metric.Gauge
RdbKeysTombstones *metric.Gauge
RdbL0BytesFlushed *metric.Gauge
RdbL0Sublevels *metric.Gauge
RdbL0NumFiles *metric.Gauge
Expand Down Expand Up @@ -2349,6 +2356,7 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics {
RdbPendingCompaction: metric.NewGauge(metaRdbPendingCompaction),
RdbMarkedForCompactionFiles: metric.NewGauge(metaRdbMarkedForCompactionFiles),
RdbKeysRangeKeySets: metric.NewGauge(metaRdbKeysRangeKeySets),
RdbKeysTombstones: metric.NewGauge(metaRdbKeysTombstones),
RdbL0BytesFlushed: metric.NewGauge(metaRdbL0BytesFlushed),
RdbL0Sublevels: metric.NewGauge(metaRdbL0Sublevels),
RdbL0NumFiles: metric.NewGauge(metaRdbL0NumFiles),
Expand Down Expand Up @@ -2677,6 +2685,7 @@ func (sm *StoreMetrics) updateEngineMetrics(m storage.Metrics) {
sm.RdbPendingCompaction.Update(int64(m.Compact.EstimatedDebt))
sm.RdbMarkedForCompactionFiles.Update(int64(m.Compact.MarkedFiles))
sm.RdbKeysRangeKeySets.Update(int64(m.Keys.RangeKeySetsCount))
sm.RdbKeysTombstones.Update(int64(m.Keys.TombstoneCount))
sm.RdbNumSSTables.Update(m.NumSSTables())
sm.RdbWriteStalls.Update(m.WriteStallCount)
sm.RdbWriteStallNanos.Update(m.WriteStallDuration.Nanoseconds())
Expand Down
4 changes: 4 additions & 0 deletions pkg/ts/catalog/chart_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3029,6 +3029,10 @@ var charts = []sectionDescription{
Title: "Range Key Set Count",
Metrics: []string{"storage.keys.range-key-set.count"},
},
{
Title: "Tombstone Count",
Metrics: []string{"storage.keys.tombstone.count"},
},
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const StatementInsightDetailsOverviewTab: React.FC<
const isCockroachCloud = useContext(CockroachCloudContext);

const insightsColumns = useMemo(
() => makeInsightsColumns(isCockroachCloud, hasAdminRole, true),
() => makeInsightsColumns(isCockroachCloud, hasAdminRole),
[isCockroachCloud, hasAdminRole],
);

Expand Down
25 changes: 15 additions & 10 deletions pkg/ui/workspaces/cluster-ui/src/insightsTable/insightsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,15 @@ const StatementExecution = ({

function descriptionCell(
insightRec: InsightRecommendation,
isExecution: boolean,
disableStmtLink: boolean,
isCockroachCloud: boolean,
isFingerprint: boolean,
): React.ReactElement {
const stmtLink = isIndexRec(insightRec) ? (
<StatementExecution rec={insightRec} disableLink={!isExecution} />
<StatementExecution
rec={insightRec}
disableLink={disableStmtLink || isFingerprint}
/>
) : null;

const clusterSettingsLink = (
Expand Down Expand Up @@ -201,15 +205,15 @@ function descriptionCell(
case "HighContention":
return (
<>
{isExecution && (
{!isFingerprint && (
<div className={cx("description-item")}>
<span className={cx("label-bold")}>Time Spent Waiting: </span>{" "}
{Duration(insightRec.details.duration * 1e6)}
</div>
)}
{stmtLink}
<div className={cx("description-item")}>
{isExecution && (
{!isFingerprint && (
<span className={cx("label-bold")}>Description: </span>
)}
{insightRec.details.description} {clusterSettingsLink}
Expand Down Expand Up @@ -272,15 +276,15 @@ function descriptionCell(
case "Unknown":
return (
<>
{isExecution && (
{!isFingerprint && (
<div className={cx("description-item")}>
<span className={cx("label-bold")}>Elapsed Time: </span>
{Duration(insightRec.details.duration * 1e6)}
</div>
)}
{stmtLink}
<div className={cx("description-item")}>
{isExecution && (
{!isFingerprint && (
<span className={cx("label-bold")}>Description: </span>
)}
{insightRec.details.description} {clusterSettingsLink}
Expand Down Expand Up @@ -390,7 +394,8 @@ const isIndexRec = (rec: InsightRecommendation) => {
export function makeInsightsColumns(
isCockroachCloud: boolean,
hasAdminRole: boolean,
isExecution?: boolean,
disableStmtLink?: boolean,
isFingerprint?: boolean,
): ColumnDescriptor<InsightRecommendation>[] {
const columns: ColumnDescriptor<InsightRecommendation>[] = [
{
Expand All @@ -403,17 +408,17 @@ export function makeInsightsColumns(
name: "details",
title: insightsTableTitles.details(),
cell: (item: InsightRecommendation) =>
descriptionCell(item, isExecution, isCockroachCloud),
descriptionCell(item, disableStmtLink, isCockroachCloud, isFingerprint),
sort: (item: InsightRecommendation) => item.type,
},
{
name: "action",
title: insightsTableTitles.actions(),
cell: (item: InsightRecommendation) =>
actionCell(item, isCockroachCloud || !hasAdminRole || !isExecution),
actionCell(item, isCockroachCloud || !hasAdminRole || isFingerprint),
},
];
if (!isExecution) {
if (isFingerprint) {
columns.push({
name: "latestExecution",
title: insightsTableTitles.latestExecution(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export function Insights({
hasAdminRole,
}: InsightsProps): React.ReactElement {
const hideAction = useContext(CockroachCloudContext) || database?.length == 0;
const insightsColumns = makeInsightsColumns(hideAction, hasAdminRole, false);
const insightsColumns = makeInsightsColumns(hideAction, hasAdminRole, true);
const data = formatIdxRecommendations(
idxRecommendations,
database,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ export class StatementDetails extends React.Component<
const insightsColumns = makeInsightsColumns(
isCockroachCloud,
this.props.hasAdminRole,
false,
true,
true,
);
const tableData: InsightRecommendation[] = [];
if (statementFingerprintInsights) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ export class TransactionDetails extends React.Component<
const insightsColumns = makeInsightsColumns(
isCockroachCloud,
this.props.hasAdminRole,
false,
true,
true,
);
const tableData: InsightRecommendation[] = [];
if (transactionInsights) {
Expand Down

0 comments on commit 4806560

Please sign in to comment.