{"record":{"id":"665d1910dc2778b8","repo":"cockroachdb/cockroach","slug":"error-while-retrieving-statements-information-s","errorCode":null,"errorMessage":"Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}","messagePattern":"Error while retrieving statements information: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts","lineNumber":365,"sourceCode":"    return null;\n  }\n\n  const contentionDetails =\n    formatTxnContentionDetailsResponse(contentionResults);\n\n  // Collect all blocking txn fingerprints involved.\n  const txnFingerprintIDs: string[] = [];\n  contentionDetails.blockingContentionDetails.forEach(x =>\n    txnFingerprintIDs.push(x.blockingTxnFingerprintID),\n  );\n\n  // Request all blocking stmt fingerprint ids involved.\n  const getStmtFingerprintsResponse =\n    await executeInternalSql<TxnStmtFingerprintsResponseColumns>(\n      makeInsightsSqlRequest([txnStmtFingerprintsQuery(txnFingerprintIDs)]),\n    );\n  if (getStmtFingerprintsResponse.error) {\n    throw new Error(\n      `Error while retrieving statements information: ${sqlApiErrorMessage(\n        getStmtFingerprintsResponse.error.message,\n      )}`,\n    );\n  }\n\n  const txnsWithStmtFingerprints = formatTxnFingerprintsResults(\n    getStmtFingerprintsResponse,\n  );\n\n  const stmtFingerprintIDs = new Set<string>();\n  txnsWithStmtFingerprints.forEach(txnFingerprint =>\n    txnFingerprint.queryIDs.forEach(id => stmtFingerprintIDs.add(id)),\n  );\n\n  // Request query string from stmt fingerprint ids.\n  let stmtQueriesResponse: SqlExecutionResponse<FingerprintStmtsResponseColumns> | null =\n    null;","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/cockroachdb/cockroach/blob/8812064a015d2faf99d3fc7e15880f94042954b0/pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts#L347-L383","documentation":"Thrown by getTxnContentionInsightDetails in cluster-ui when the internal SQL request for the blocking transactions' statement fingerprints fails. executeInternalSql runs txnStmtFingerprintsQuery (crdb_internal.transaction_statement_statistics) with the blockingTxnFingerprintIDs collected from the contention event; any non-nil response error is wrapped by sqlApiErrorMessage and re-thrown, aborting the contention insight detail. Unlike txnInsightDetailsApi, this site does NOT exempt max-size errors, so a 'result size exceeds limit' error also throws here.","triggerScenarios":"Opening the transaction contention insight details for a contention event that has blocking txn fingerprints, and the SQL API response carries res.error: query failure on crdb_internal tables, permission denial for the console user, RPC/gateway error to the SQL API, or an oversized result set (not exempted at this call site).","commonSituations":"Clusters with huge statement fingerprint histories hitting the SQL API max response size; non-admin UI users lacking read access to crdb_internal.transaction_statement_statistics; mixed-version clusters mid-upgrade where the internal table schema moved; transient node unavailability while the insights page loads.","solutions":["Read the text after 'Error while retrieving statements information:' — it is the underlying SQL API error and names the real failure","If it is a max-size error, narrow the insight request time range or reduce fingerprint retention (cluster settings under sql.metrics.*) so the query fits the limit","Run the generated txnStmtFingerprintsQuery manually in a SQL shell as the same console user to reproduce and check privileges","Check server logs for the failing crdb_internal query and confirm all nodes run the same version"],"exampleFix":"// before\nif (getStmtFingerprintsResponse.error) {\n  throw new Error(`Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}`);\n}\n\n// after: exempt max-size errors like txnInsightDetailsApi.ts does\nconst maxSize = isMaxSizeError(getStmtFingerprintsResponse.error?.message);\nif (getStmtFingerprintsResponse.error && !maxSize) {\n  throw new Error(`Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}`);\n}","handlingStrategy":"try-catch","validationCode":"// Pre-limit the fingerprint list so the query cannot blow the response limit\nconst txnFingerprintIDs = contentionDetails.blockingContentionDetails\n  .map(x => x.blockingTxnFingerprintID)\n  .slice(0, 500); // cap proportional to your sqlApi result limit\nif (txnFingerprintIDs.length === 0) {\n  return buildTxnContentionInsightDetails(contentionDetails, [], new Map());\n}","typeGuard":"const hasSqlApiError = (\n  r: SqlExecutionResponse<unknown>,\n): r is SqlExecutionResponse<unknown> & { error: SqlExecutionErrorMessage } =>\n  !!r.error;","tryCatchPattern":"try {\n  const details = await getTxnContentionInsightDetails(req);\n} catch (e) {\n  // Degrade the insights page instead of crashing: show the inner SQL message\n  setError(e instanceof Error ? e.message : 'Failed to load contention insight');\n}","preventionTips":["Keep statement/txn fingerprint retention modest so fingerprint queries stay under the SQL API size limit","Give the console user read access to the crdb_internal tables used by insights","Version-match the console bundle with the cluster during rolling upgrades"],"tags":["cluster-ui","sql-api","contention","insights","typescript"],"backgroundTag":null,"analyzedSha":"8812064a015d2faf99d3fc7e15880f94042954b0","analyzedAt":"2026-08-15T16:34:17.351Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}