cockroachdb/cockroach · error · Error

Error while retrieving statements information: ${sqlApiError

Error message

Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}

What it means

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.

Source

Thrown at pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts:365

    return null;
  }

  const contentionDetails =
    formatTxnContentionDetailsResponse(contentionResults);

  // Collect all blocking txn fingerprints involved.
  const txnFingerprintIDs: string[] = [];
  contentionDetails.blockingContentionDetails.forEach(x =>
    txnFingerprintIDs.push(x.blockingTxnFingerprintID),
  );

  // Request all blocking stmt fingerprint ids involved.
  const getStmtFingerprintsResponse =
    await executeInternalSql<TxnStmtFingerprintsResponseColumns>(
      makeInsightsSqlRequest([txnStmtFingerprintsQuery(txnFingerprintIDs)]),
    );
  if (getStmtFingerprintsResponse.error) {
    throw new Error(
      `Error while retrieving statements information: ${sqlApiErrorMessage(
        getStmtFingerprintsResponse.error.message,
      )}`,
    );
  }

  const txnsWithStmtFingerprints = formatTxnFingerprintsResults(
    getStmtFingerprintsResponse,
  );

  const stmtFingerprintIDs = new Set<string>();
  txnsWithStmtFingerprints.forEach(txnFingerprint =>
    txnFingerprint.queryIDs.forEach(id => stmtFingerprintIDs.add(id)),
  );

  // Request query string from stmt fingerprint ids.
  let stmtQueriesResponse: SqlExecutionResponse<FingerprintStmtsResponseColumns> | null =
    null;

View on GitHub (pinned to 8812064a01)

Solutions

  1. Read the text after 'Error while retrieving statements information:' — it is the underlying SQL API error and names the real failure
  2. 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
  3. Run the generated txnStmtFingerprintsQuery manually in a SQL shell as the same console user to reproduce and check privileges
  4. Check server logs for the failing crdb_internal query and confirm all nodes run the same version

Example fix

// before
if (getStmtFingerprintsResponse.error) {
  throw new Error(`Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}`);
}

// after: exempt max-size errors like txnInsightDetailsApi.ts does
const maxSize = isMaxSizeError(getStmtFingerprintsResponse.error?.message);
if (getStmtFingerprintsResponse.error && !maxSize) {
  throw new Error(`Error while retrieving statements information: ${sqlApiErrorMessage(getStmtFingerprintsResponse.error.message)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-limit the fingerprint list so the query cannot blow the response limit
const txnFingerprintIDs = contentionDetails.blockingContentionDetails
  .map(x => x.blockingTxnFingerprintID)
  .slice(0, 500); // cap proportional to your sqlApi result limit
if (txnFingerprintIDs.length === 0) {
  return buildTxnContentionInsightDetails(contentionDetails, [], new Map());
}

Type guard

const hasSqlApiError = (
  r: SqlExecutionResponse<unknown>,
): r is SqlExecutionResponse<unknown> & { error: SqlExecutionErrorMessage } =>
  !!r.error;

Try / catch

try {
  const details = await getTxnContentionInsightDetails(req);
} catch (e) {
  // Degrade the insights page instead of crashing: show the inner SQL message
  setError(e instanceof Error ? e.message : 'Failed to load contention insight');
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of cockroachdb/cockroach@8812064a01 (2026-08-15). Data as JSON: /api/errors/665d1910dc2778b8. Report an issue: GitHub.