Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
86695: sql: Update pgjdbc blocklist r=rafiss a=e-mbrown

Closes cockroachdb#85882

Release justification: Non-production code changes
Release note: None

87171: ui: add columns and column selector to statement insights r=j82w a=j82w

Adds column selector to statement insights page and adds 
new contention, full scan, transaction id, transaction fingerprint id,
and rows read/written.

closes cockroachdb#87021

https://www.loom.com/share/d4d6f567cefe4928a62cfbe39e9d15e0

Release justification: Category 2: Bug fixes and
low-risk updates to new functionality

Release note (ui change): Adds column selector to
statement insights page and adds new contention,
full scan, transaction id, transaction fingerprint id,
and rows read/written.

Co-authored-by: e-mbrown <[email protected]>
Co-authored-by: j82w <[email protected]>
  • Loading branch information
3 people committed Aug 31, 2022
3 parents 0602871 + 402a448 + c42be29 commit 121ead5
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 2,667 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/blocklist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestBlocklists(t *testing.T) {

blocklists := map[string]blocklist{
"hibernate": hibernateBlockList20_2,
"pgjdbc": pgjdbcBlockList20_2,
"pgjdbc": pgjdbcBlockList,
"psycopg": psycopgBlockList20_2,
"django": djangoBlocklist20_2,
"sqlAlchemy": sqlAlchemyBlocklist20_2,
Expand Down
17 changes: 8 additions & 9 deletions pkg/cmd/roachtest/tests/pgjdbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,14 @@ func registerPgjdbc(r registry.Registry) {
t.Fatal(err)
}

blocklistName, expectedFailures, ignorelistName, ignorelist := pgjdbcBlocklists.getLists(version)
if expectedFailures == nil {
t.Fatalf("No pgjdbc blocklist defined for cockroach version %s", version)
}
status := fmt.Sprintf("Running cockroach version %s, using blocklist %s", version, blocklistName)
if ignorelist != nil {
status = fmt.Sprintf("Running cockroach version %s, using blocklist %s, using ignorelist %s",
version, blocklistName, ignorelistName)
}
const blocklistName = "pgjdbcBlocklist"
const ignorelistName = "pgjdbcIgnorelist"
expectedFailures := pgjdbcBlockList
ignorelist := pgjdbcIgnoreList

status := fmt.Sprintf("Running cockroach version %s, using blocklist %s, using ignorelist %s",
version, blocklistName, ignorelistName)

t.L().Printf("%s", status)

t.Status("running pgjdbc test suite")
Expand Down
2,567 changes: 2 additions & 2,565 deletions pkg/cmd/roachtest/tests/pgjdbc_blocklist.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { StatementInsightsViewProps } from "./statementInsightsView";
import moment from "moment";

export const statementInsightsPropsFixture: StatementInsightsViewProps = {
onColumnsChange: x => {},
selectedColumnNames: [],
statements: [
{
statementID: "f72f37ea-b3a0-451f-80b8-dfb27d0bc2a9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SortedTable,
SortSetting,
} from "src/sortedtable";
import { DATE_FORMAT, Duration, limitText } from "src/util";
import { Count, DATE_FORMAT, Duration, limitText } from "src/util";
import { InsightExecEnum, StatementInsightEvent } from "src/insights";
import { InsightCell, insightsTableTitles } from "../util";
import { StatementInsights } from "../../../api";
Expand All @@ -32,6 +32,7 @@ interface StatementInsightsTable {
onChangeSortSetting: (ss: SortSetting) => void;
pagination: ISortedTablePagination;
renderNoResult?: React.ReactNode;
visibleColumns: ColumnDescriptor<StatementInsightEvent>[];
}

export function makeStatementInsightsColumns(): ColumnDescriptor<StatementInsightEvent>[] {
Expand All @@ -46,12 +47,14 @@ export function makeStatementInsightsColumns(): ColumnDescriptor<StatementInsigh
</Link>
),
sort: (item: StatementInsightEvent) => item.statementID,
alwaysShow: true,
},
{
name: "statementFingerprintID",
title: insightsTableTitles.fingerprintID(execType),
cell: (item: StatementInsightEvent) => item.statementFingerprintID,
sort: (item: StatementInsightEvent) => item.statementFingerprintID,
showByDefault: true,
},
{
name: "query",
Expand All @@ -62,6 +65,7 @@ export function makeStatementInsightsColumns(): ColumnDescriptor<StatementInsigh
</Tooltip>
),
sort: (item: StatementInsightEvent) => item.query,
showByDefault: true,
},
{
name: "insights",
Expand All @@ -72,47 +76,97 @@ export function makeStatementInsightsColumns(): ColumnDescriptor<StatementInsigh
item.insights
? item.insights.map(insight => insight.label).toString()
: "",
showByDefault: true,
},
{
name: "startTime",
title: insightsTableTitles.startTime(execType),
cell: (item: StatementInsightEvent) => item.startTime.format(DATE_FORMAT),
sort: (item: StatementInsightEvent) => item.startTime.unix(),
showByDefault: true,
},
{
name: "elapsedTime",
title: insightsTableTitles.elapsedTime(execType),
cell: (item: StatementInsightEvent) =>
Duration(item.elapsedTimeMillis * 1e6),
sort: (item: StatementInsightEvent) => item.elapsedTimeMillis,
showByDefault: true,
},
{
name: "userName",
title: insightsTableTitles.username(execType),
cell: (item: StatementInsightEvent) => item.username,
sort: (item: StatementInsightEvent) => item.username,
showByDefault: true,
},
{
name: "applicationName",
title: insightsTableTitles.applicationName(execType),
cell: (item: StatementInsightEvent) => item.application,
sort: (item: StatementInsightEvent) => item.application,
showByDefault: true,
},
{
name: "rowsProcessed",
title: insightsTableTitles.rowsProcessed(execType),
className: cx("statements-table__col-rows-read"),
cell: (item: StatementInsightEvent) =>
`${Count(item.rowsRead)} Reads / ${Count(item.rowsRead)} Writes`,
sort: (item: StatementInsightEvent) => item.rowsRead + item.rowsWritten,
showByDefault: true,
},
{
name: "retries",
title: insightsTableTitles.numRetries(execType),
cell: (item: StatementInsightEvent) => item.retries,
sort: (item: StatementInsightEvent) => item.retries,
showByDefault: false,
},
{
name: "contention",
title: insightsTableTitles.contention(execType),
cell: (item: StatementInsightEvent) =>
!item.timeSpentWaiting
? "no samples"
: Duration(item.timeSpentWaiting.asMilliseconds() * 1e6),
sort: (item: StatementInsightEvent) =>
item.timeSpentWaiting?.asMilliseconds() ?? -1,
showByDefault: false,
},
{
name: "isFullScan",
title: insightsTableTitles.isFullScan(execType),
cell: (item: StatementInsightEvent) => String(item.isFullScan),
sort: (item: StatementInsightEvent) => String(item.isFullScan),
showByDefault: false,
},
{
name: "transactionID",
title: insightsTableTitles.executionID(InsightExecEnum.TRANSACTION),
cell: (item: StatementInsightEvent) => item.transactionID,
sort: (item: StatementInsightEvent) => item.transactionID,
showByDefault: false,
},
{
name: "transactionFingerprintID",
title: insightsTableTitles.fingerprintID(InsightExecEnum.TRANSACTION),
cell: (item: StatementInsightEvent) => item.transactionFingerprintID,
sort: (item: StatementInsightEvent) => item.transactionFingerprintID,
showByDefault: false,
},
];
}

export const StatementInsightsTable: React.FC<
StatementInsightsTable
> = props => {
const columns = makeStatementInsightsColumns();
return (
<SortedTable columns={columns} className="statements-table" {...props} />
<SortedTable
columns={props.visibleColumns}
className="statements-table"
{...props}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React, { useEffect, useState } from "react";
import classNames from "classnames/bind";
import { useHistory } from "react-router-dom";
import {
ColumnDescriptor,
ISortedTablePagination,
SortSetting,
} from "src/sortedtable/sortedtable";
Expand All @@ -34,15 +35,19 @@ import { StatementInsights } from "src/api/insightsApi";
import {
filterStatementInsights,
getAppsFromStatementInsights,
makeStatementInsightsColumns,
WorkloadInsightEventFilters,
populateStatementInsightsFromProblems,
StatementInsightEvent,
} from "src/insights";
import { EmptyInsightsTablePlaceholder } from "../util";
import { StatementInsightsTable } from "./statementInsightsTable";
import { InsightsError } from "../../insightsErrorComponent";

import styles from "src/statementsPage/statementsPage.module.scss";
import sortableTableStyles from "src/sortedtable/sortedtable.module.scss";
import ColumnsSelector from "../../../columnsSelector/columnsSelector";
import { SelectOption } from "../../../multiSelectCheckbox/multiSelectCheckbox";

const cx = classNames.bind(styles);
const sortableTableCx = classNames.bind(sortableTableStyles);
Expand All @@ -52,13 +57,15 @@ export type StatementInsightsViewStateProps = {
statementsError: Error | null;
filters: WorkloadInsightEventFilters;
sortSetting: SortSetting;
selectedColumnNames: string[];
dropDownSelect?: React.ReactElement;
};

export type StatementInsightsViewDispatchProps = {
onFiltersChange: (filters: WorkloadInsightEventFilters) => void;
onSortChange: (ss: SortSetting) => void;
refreshStatementInsights: () => void;
onColumnsChange: (selectedColumns: string[]) => void;
};

export type StatementInsightsViewProps = StatementInsightsViewStateProps &
Expand All @@ -67,6 +74,21 @@ export type StatementInsightsViewProps = StatementInsightsViewStateProps &
const INSIGHT_STMT_SEARCH_PARAM = "q";
const INTERNAL_APP_NAME_PREFIX = "$ internal";

function isSelected(
column: ColumnDescriptor<StatementInsightEvent>,
selectedColumns: string[],
): boolean {
if (column.alwaysShow) {
return true;
}

if (selectedColumns === null || selectedColumns === undefined) {
return column.showByDefault;
}

return selectedColumns.includes(column.name);
}

export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
props: StatementInsightsViewProps,
) => {
Expand All @@ -78,6 +100,8 @@ export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
refreshStatementInsights,
onFiltersChange,
onSortChange,
onColumnsChange,
selectedColumnNames,
dropDownSelect,
} = props;

Expand Down Expand Up @@ -170,6 +194,12 @@ export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
resetPagination();
};

const defaultColumns = makeStatementInsightsColumns();

const visibleColumns = defaultColumns.filter(x =>
isSelected(x, selectedColumnNames),
);

const clearFilters = () =>
onSubmitFilters({
app: defaultFilters.app,
Expand All @@ -188,6 +218,15 @@ export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
);

populateStatementInsightsFromProblems(filteredStatements);
const tableColumns = defaultColumns
.filter(c => !c.alwaysShow)
.map(
(c): SelectOption => ({
label: (c.title as React.ReactElement).props.children,
value: c.name,
isSelected: isSelected(c, selectedColumnNames),
}),
);

return (
<div className={cx("root")}>
Expand Down Expand Up @@ -220,6 +259,10 @@ export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
<div>
<section className={sortableTableCx("cl-table-container")}>
<div>
<ColumnsSelector
options={tableColumns}
onSubmitColumns={onColumnsChange}
/>
<TableStatistics
pagination={pagination}
search={search}
Expand All @@ -232,6 +275,7 @@ export const StatementInsightsView: React.FC<StatementInsightsViewProps> = (
<StatementInsightsTable
data={filteredStatements}
sortSetting={sortSetting}
visibleColumns={visibleColumns}
onChangeSortSetting={onChangeSortSetting}
renderNoResult={
<EmptyInsightsTablePlaceholder
Expand Down
Loading

0 comments on commit 121ead5

Please sign in to comment.