Skip to content

fix(Overview): use stats from describe for all column tables #1026

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

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/containers/Tenant/Diagnostics/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ interface OverviewProps {
function Overview({type, path}: OverviewProps) {
const [autoRefreshInterval] = useAutoRefreshInterval();

// FIXME: The request is too heavy, stats table may have millions of items
// Disabled until fixed
// https://github.com/ydb-platform/ydb-embedded-ui/issues/907
// https://github.com/ydb-platform/ydb-embedded-ui/issues/908
// const olapParams = isTableType(type) && isColumnEntityType(type) ? {path} : skipToken;
// const {currentData: olapData, isFetching: olapIsFetching} = olapApi.useGetOlapStatsQuery(
// olapParams,
// {pollingInterval: autoRefreshInterval},
// );
// const olapStatsLoading = olapIsFetching && olapData === undefined;
// const {result: olapStats} = olapData || {result: undefined};

const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);

// shallowEqual prevents rerenders when new schema data is loaded
Expand Down Expand Up @@ -70,7 +58,6 @@ function Overview({type, path}: OverviewProps) {

const {error: schemaError} = useGetSchemaQuery({path});

// overviewLoading || olapStatsLoading
const entityLoading = overviewLoading;
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;

Expand All @@ -97,15 +84,7 @@ function Overview({type, path}: OverviewProps) {
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
};

return (
(type && pathTypeToComponent[type]?.()) || (
<TableInfo
data={data}
type={type}
// olapStats={olapStats}
/>
)
);
return (type && pathTypeToComponent[type]?.()) || <TableInfo data={data} type={type} />;
};

if (entityLoading || entityNotReady) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {InfoViewer} from '../../../../../components/InfoViewer';
import type {KeyValueRow} from '../../../../../types/api/query';
import type {EPathType, TEvDescribeSchemeResult} from '../../../../../types/api/schema';
import {cn} from '../../../../../utils/cn';
import {EntityTitle} from '../../../EntityTitle/EntityTitle';
Expand All @@ -16,18 +15,17 @@ const b = cn('ydb-diagnostics-table-info');
interface TableInfoProps {
data?: TEvDescribeSchemeResult;
type?: EPathType;
olapStats?: KeyValueRow[];
}

export const TableInfo = ({data, type, olapStats}: TableInfoProps) => {
export const TableInfo = ({data, type}: TableInfoProps) => {
const title = <EntityTitle data={data?.PathDescription} />;

const {
generalInfo,
tableStatsInfo,
tabletMetricsInfo = [],
partitionConfigInfo = [],
} = React.useMemo(() => prepareTableInfo(data, type, olapStats), [data, type, olapStats]);
} = React.useMemo(() => prepareTableInfo(data, type), [data, type]);

return (
<div className={b()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
formatTableStatsItem,
formatTabletMetricsItem,
} from '../../../../../components/InfoViewer/formatters';
import type {KeyValueRow} from '../../../../../types/api/query';
import type {
TColumnDataLifeCycle,
TColumnTableDescription,
Expand All @@ -17,34 +16,12 @@ import type {
import {EPathType} from '../../../../../types/api/schema';
import {formatBytes, formatNumber} from '../../../../../utils/dataFormatters/dataFormatters';
import {formatDurationToShortTimeFormat} from '../../../../../utils/timeParsers';
import {isNumeric} from '../../../../../utils/utils';

const isInStoreColumnTable = (table: TColumnTableDescription) => {
// SchemaPresetId could be 0
return table.SchemaPresetName && table.SchemaPresetId !== undefined;
};

const prepareOlapStats = (olapStats: KeyValueRow[]) => {
const Bytes = olapStats?.reduce((acc, el) => {
const value = isNumeric(el.Bytes) ? Number(el.Bytes) : 0;
return acc + value;
}, 0);
const Rows = olapStats?.reduce((acc, el) => {
const value = isNumeric(el.Rows) ? Number(el.Rows) : 0;
return acc + value;
}, 0);
const tabletIds = olapStats?.reduce((acc, el) => {
acc.add(el.TabletId);
return acc;
}, new Set());

return [
{label: 'PartCount', value: tabletIds?.size ?? 0},
{label: 'RowCount', value: formatNumber(Rows) ?? 0},
{label: 'DataSize', value: formatBytes(Bytes) ?? 0},
];
};

const prepareTTL = (ttl: TTTLSettings | TColumnDataLifeCycle) => {
// ExpireAfterSeconds could be 0
if (ttl.Enabled && ttl.Enabled.ColumnName && ttl.Enabled.ExpireAfterSeconds !== undefined) {
Expand Down Expand Up @@ -143,11 +120,7 @@ const prepareTableGeneralInfo = (PartitionConfig: TPartitionConfig, TTLSettings?
};

/** Prepares data for Table, ColumnTable and ColumnStore */
export const prepareTableInfo = (
data?: TEvDescribeSchemeResult,
type?: EPathType,
olapStats?: KeyValueRow[],
) => {
export const prepareTableInfo = (data?: TEvDescribeSchemeResult, type?: EPathType) => {
if (!data) {
return {};
}
Expand Down Expand Up @@ -199,43 +172,33 @@ export const prepareTableInfo = (
}
}

let tableStatsInfo: InfoViewerItem[][] | undefined;

// There is no TableStats and TabletMetrics for ColumnTables inside ColumnStore
// Therefore we parse olapStats
if (type === EPathType.EPathTypeColumnTable && isInStoreColumnTable(ColumnTableDescription)) {
if (olapStats) {
tableStatsInfo = [prepareOlapStats(olapStats)];
}
} else {
tableStatsInfo = [
formatObject(formatTableStatsItem, {
PartCount,
RowCount,
DataSize,
IndexSize,
}),
formatObject(formatTableStatsItem, {
LastAccessTime,
LastUpdateTime,
}),
formatObject(formatTableStatsItem, {
ImmediateTxCompleted,
PlannedTxCompleted,
TxRejectedByOverload,
TxRejectedBySpace,
TxCompleteLagMsec,
InFlightTxCount,
}),
formatObject(formatTableStatsItem, {
RowUpdates,
RowDeletes,
RowReads,
RangeReads,
RangeReadRows,
}),
];
}
const tableStatsInfo = [
formatObject(formatTableStatsItem, {
PartCount,
RowCount,
DataSize,
IndexSize,
}),
formatObject(formatTableStatsItem, {
LastAccessTime,
LastUpdateTime,
}),
formatObject(formatTableStatsItem, {
ImmediateTxCompleted,
PlannedTxCompleted,
TxRejectedByOverload,
TxRejectedBySpace,
TxCompleteLagMsec,
InFlightTxCount,
}),
formatObject(formatTableStatsItem, {
RowUpdates,
RowDeletes,
RowReads,
RangeReads,
RangeReadRows,
}),
];

//@ts-expect-error
const tabletMetricsInfo = formatObject(formatTabletMetricsItem, TabletMetrics);
Expand Down
39 changes: 0 additions & 39 deletions src/store/reducers/olapStats.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/types/api/schema/columnEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export interface TColumnTableDescription {
Schema?: TColumnTableSchema;
TtlSettings?: TColumnDataLifeCycle;

SchemaPresetId?: number;
SchemaPresetName?: string;
SchemaPresetId?: number; // For in-store column tables, could be 0
SchemaPresetName?: string; // For in-store column tables

ColumnStorePathId?: TPathID;

Expand Down
Loading