Skip to content

Commit

Permalink
ui: add error message for failed executions
Browse files Browse the repository at this point in the history
Part of #87785

This commit adds the error message for failed executions to the
statement and transaction insights pages. Since this value can contain
sensitive information, it must conform to the VIEWACTIVITY and
VIEWACTIVITYREDACTED system privielges.

Release note (ui change): adds "Error message" row to the statement and
transaction insights details pages. If the user has VIEWACTIVITY, they
are able to view the full error message. If they have
VIEWACTIVTYREDACTED, they are given a redacted error message. If they
have both, VIEWACTIVITYTREDACTED  takes precedence.
  • Loading branch information
gtr authored and xinhaoz committed Sep 22, 2023
1 parent 3c0be00 commit 8cc84b4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type StmtInsightsResponseRow = {
plan_gist: string;
cpu_sql_nanos: number;
error_code: string;
last_error_redactable: string;
status: StatementStatus;
};

Expand Down Expand Up @@ -95,6 +96,7 @@ index_recommendations,
plan_gist,
cpu_sql_nanos,
error_code,
last_error_redactable,
status
`;

Expand Down Expand Up @@ -242,6 +244,7 @@ export function formatStmtInsights(
planGist: row.plan_gist,
cpuSQLNanos: row.cpu_sql_nanos,
errorCode: row.error_code,
errorMsg: row.last_error_redactable,
status: row.status,
} as StmtInsightEvent;
});
Expand Down
3 changes: 3 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ type TxnInsightsResponseRow = {
stmt_execution_ids: string[];
cpu_sql_nanos: number;
last_error_code: string;
last_error_redactable: string;
status: TransactionStatus;
};

Expand Down Expand Up @@ -334,6 +335,7 @@ causes,
stmt_execution_ids,
cpu_sql_nanos,
last_error_code,
last_error_redactable,
status`;

if (filters?.execID) {
Expand Down Expand Up @@ -403,6 +405,7 @@ function formatTxnInsightsRow(row: TxnInsightsResponseRow): TxnInsightEvent {
stmtExecutionIDs: row.stmt_execution_ids,
cpuSQLNanos: row.cpu_sql_nanos,
errorCode: row.last_error_code,
errorMsg: row.last_error_redactable,
status: row.status,
};
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/insights/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type InsightEventBase = {
transactionFingerprintID: string;
username: string;
errorCode: string;
errorMsg: string;
};

export type TxnInsightEvent = InsightEventBase & {
Expand Down Expand Up @@ -114,6 +115,7 @@ export type StmtInsightEvent = InsightEventBase & {
databaseName: string;
execType?: InsightExecEnum;
status: StatementStatus;
errorMsg?: string;
};

export type Insight = {
Expand Down Expand Up @@ -344,6 +346,7 @@ export interface ExecutionDetails {
transactionExecutionID?: string;
execType?: InsightExecEnum;
errorCode?: string;
errorMsg?: string;
status?: string;
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/insights/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const statementInsightMock: StmtInsightEvent = {
planGist: "gist",
cpuSQLNanos: 50,
errorCode: "",
errorMsg: "",
status: StatementStatus.COMPLETED,
};

Expand Down Expand Up @@ -121,6 +122,7 @@ const txnInsightEventMock: TxnInsightEvent = {
stmtExecutionIDs: [statementInsightMock.statementExecutionID],
cpuSQLNanos: 50,
errorCode: "",
errorMsg: "",
status: TransactionStatus.COMPLETED,
};

Expand Down
2 changes: 2 additions & 0 deletions pkg/ui/workspaces/cluster-ui/src/insights/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export function getStmtInsightRecommendations(
transactionExecutionID: insightDetails.transactionExecutionID,
execType: InsightExecEnum.STATEMENT,
errorCode: insightDetails.errorCode,
errorMsg: insightDetails.errorMsg,
status: insightDetails.status,
};

Expand All @@ -431,6 +432,7 @@ export function getTxnInsightRecommendations(
elapsedTimeMillis: insightDetails.elapsedTimeMillis,
execType: InsightExecEnum.TRANSACTION,
errorCode: insightDetails.errorCode,
errorMsg: insightDetails.errorMsg,
};
const recs: InsightRecommendation[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ function descriptionCell(
<span className={cx("label-bold")}>Error Code: </span>{" "}
{insightRec.execution.errorCode}
</div>
<div className={cx("description-item")}>
<span className={cx("label-bold")}> Error Message: </span>{" "}
{insightRec.execution.errorMsg}
</div>
</>
);
case "Unknown":
Expand Down

0 comments on commit 8cc84b4

Please sign in to comment.