Skip to content

Commit 59c110c

Browse files
craig[bot]kyle-a-wong
andcommitted
Merge #155149
155149: Revert "ui: fix statement activity timepicker for sub-hour ranges" r=kyle-a-wong a=kyle-a-wong This reverts commit a444987. This PR was intended to allow the sql activity timepicker to support sub 1-hour time ranges. Previously, any time range selected, whether a preset or an explicit range, always rounded to the top of the previous hour. The commit being reverted made changes to some of the components that rounded the time, but not all of them. It also introduced a new type of bug that could potentially cause the sql activity page to miss expected sql activity statistics. Due to the latter bug that was mentioned, we are opting to revert this change as its sql stats aggregation buckets are almost always set to 1 hour and is not a public setting we advise for people to change. Fixes: https://cockroachlabs.atlassian.net/browse/CC-33789 Epic: CC-33582 Release note: None Co-authored-by: Kyle Wong <[email protected]>
2 parents 588e5f6 + 862b5b3 commit 59c110c

File tree

6 files changed

+15
-29
lines changed

6 files changed

+15
-29
lines changed

pkg/ui/workspaces/cluster-ui/src/api/indexDetailsApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020

2121
import { INTERNAL_APP_NAME_PREFIX } from "../activeExecutions/activeStatementUtils";
2222
import { AggregateStatistics } from "../statementsTable";
23-
import { TimeScale, toDateRange } from "../timeScaleDropdown";
23+
import { TimeScale, toRoundedDateRange } from "../timeScaleDropdown";
2424

2525
export type TableIndexStatsRequest =
2626
cockroach.server.serverpb.TableIndexStatsRequest;
@@ -77,7 +77,7 @@ export function StatementsListRequestFromDetails(
7777
ts: TimeScale,
7878
): StatementsUsingIndexRequest {
7979
if (ts === null) return { table, index, database };
80-
const [start, end] = toDateRange(ts);
80+
const [start, end] = toRoundedDateRange(ts);
8181
return { table, index, database, start, end };
8282
}
8383

pkg/ui/workspaces/cluster-ui/src/searchCriteria/searchCriteria.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
// included in the /LICENSE file.
55

66
import { CaretDown } from "@cockroachlabs/icons";
7-
import { InlineAlert } from "@cockroachlabs/ui-components";
87
import { Menu, Dropdown } from "antd";
98
import classNames from "classnames/bind";
10-
import moment from "moment-timezone";
119
import { MenuClickEventHandler } from "rc-menu/es/interface";
1210
import React from "react";
1311

@@ -19,7 +17,6 @@ import {
1917
TimeScale,
2018
timeScale1hMinOptions,
2119
TimeScaleDropdown,
22-
toDateRange,
2320
} from "src/timeScaleDropdown";
2421

2522
import { applyBtn } from "../queryFilter/filterClasses";
@@ -63,11 +60,6 @@ export function SearchCriteria(props: SearchCriteriaProps): React.ReactElement {
6360
onChangeBy,
6461
onChangeTimeScale,
6562
} = props;
66-
67-
// Check if selected time range is less than 1 hour
68-
const [start, end] = toDateRange(currentScale);
69-
const duration = moment.duration(end.diff(start));
70-
const isSubHourRange = duration.asHours() < 1;
7163
const sortOptions: SortOption[] =
7264
searchType === "Statement" ? stmtRequestSortOptions : txnRequestSortOptions;
7365
const sortMoreOptions: SortOption[] =
@@ -127,14 +119,6 @@ export function SearchCriteria(props: SearchCriteriaProps): React.ReactElement {
127119
return (
128120
<div className={cx("search-area")}>
129121
<h5 className={commonStyles("base-heading")}>Search Criteria</h5>
130-
{isSubHourRange && (
131-
<div style={{ marginBottom: "16px" }}>
132-
<InlineAlert
133-
intent="warning"
134-
title="Sub-hour time range selected: Statement statistics are aggregated hourly by default. You may not see data for time ranges less than 1 hour if the aggregation interval has not elapsed yet. Adjust the sql.stats.aggregation.interval cluster setting if you need finer granularity."
135-
/>
136-
</div>
137-
)}
138122
<PageConfig className={cx("top-area")}>
139123
<PageConfigItem>
140124
<label>

pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.selectors.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { RouteComponentProps } from "react-router-dom";
1111

1212
import { AppState } from "../store";
1313
import { selectTimeScale } from "../store/utils/selectors";
14-
import { TimeScale, toDateRange } from "../timeScaleDropdown";
14+
import { TimeScale, toRoundedDateRange } from "../timeScaleDropdown";
1515
import {
1616
appNamesAttr,
1717
statementAttr,
@@ -41,10 +41,12 @@ export const selectStatementDetails = createSelector(
4141
lastError: Error;
4242
lastUpdated: moment.Moment | null;
4343
} => {
44-
// Use the exact time range selected by the user, not rounded to hour boundaries.
45-
// This allows for more granular time ranges when sql.stats.aggregation.interval
46-
// is set to a value smaller than 1 hour.
47-
const [start, end] = toDateRange(timeScale);
44+
// Since the aggregation interval is 1h, we want to round the selected timeScale to include
45+
// the full hour. If a timeScale is between 14:32 - 15:17 we want to search for values
46+
// between 14:00 - 16:00. We don't encourage the aggregation interval to be modified, but
47+
// in case that changes in the future we might consider changing this function to use the
48+
// cluster settings value for the rounding function.
49+
const [start, end] = toRoundedDateRange(timeScale);
4850
const key = generateStmtDetailsToID(
4951
fingerprintID,
5052
appNames,

pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import {
8888
getValidOption,
8989
TimeScale,
9090
timeScale1hMinOptions,
91-
toDateRange,
91+
toRoundedDateRange,
9292
} from "../timeScaleDropdown";
9393
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";
9494

@@ -175,7 +175,7 @@ type RequestParams = Pick<
175175
>;
176176

177177
function stmtsRequestFromParams(params: RequestParams): StatementsRequest {
178-
const [start, end] = toDateRange(params.timeScale);
178+
const [start, end] = toRoundedDateRange(params.timeScale);
179179
return createCombinedStmtsRequest({
180180
start,
181181
end,

pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import {
7979
timeScale1hMinOptions,
8080
TimeScaleDropdown,
8181
timeScaleRangeToObj,
82-
toDateRange,
82+
toRoundedDateRange,
8383
} from "../timeScaleDropdown";
8484
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";
8585
import { baseHeadingClasses } from "../transactionsPage/transactionsPageClasses";
@@ -143,7 +143,7 @@ interface TState {
143143
function statementsRequestFromProps(
144144
props: TransactionDetailsProps,
145145
): StatementsRequest {
146-
const [start, end] = toDateRange(props.timeScale);
146+
const [start, end] = toRoundedDateRange(props.timeScale);
147147
return createCombinedStmtsRequest({
148148
start,
149149
end,

pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import {
6666
TimeScale,
6767
timeScale1hMinOptions,
6868
getValidOption,
69-
toDateRange,
69+
toRoundedDateRange,
7070
} from "../timeScaleDropdown";
7171
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";
7272
import {
@@ -140,7 +140,7 @@ export type TransactionsPageProps = TransactionsPageStateProps &
140140
type RequestParams = Pick<TState, "timeScale" | "limit" | "reqSortSetting">;
141141

142142
function stmtsRequestFromParams(params: RequestParams): StatementsRequest {
143-
const [start, end] = toDateRange(params.timeScale);
143+
const [start, end] = toRoundedDateRange(params.timeScale);
144144
return createCombinedStmtsRequest({
145145
start,
146146
end,

0 commit comments

Comments
 (0)