cockroachdb/cockroach · error · Error
Error while retrieving statements information: ${sqlApiError
Error message
Error while retrieving statements information: ${sqlApiErrorMessage(stmtQueriesResponse.error.message)} What it means
Second failure point in getTxnContentionInsightDetails: after statement fingerprint IDs are extracted from the txn fingerprints, the query strings are fetched via fingerprintStmtsQuery (crdb_internal.statement_statistics) and any response error is thrown with the same 'retrieving statements information' context. The query only runs when stmtFingerprintIDs.size > 0, so the txn-fingerprint step must have succeeded first.
Source
Thrown at pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts:393
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;
if (stmtFingerprintIDs.size) {
stmtQueriesResponse =
await executeInternalSql<FingerprintStmtsResponseColumns>(
makeInsightsSqlRequest([
fingerprintStmtsQuery(Array.from(stmtFingerprintIDs)),
]),
);
if (stmtQueriesResponse.error) {
throw new Error(
`Error while retrieving statements information: ${sqlApiErrorMessage(
stmtQueriesResponse.error.message,
)}`,
);
}
}
return buildTxnContentionInsightDetails(
contentionDetails,
txnsWithStmtFingerprints,
createStmtFingerprintToQueryMap(stmtQueriesResponse),
);
}
View on GitHub (pinned to 8812064a01)
Solutions
- Inspect the sqlApiErrorMessage suffix for the concrete SQL error
- For max-size errors, shrink the request: fewer blocking fingerprints or a narrower contention time window
- Execute the fingerprintStmtsQuery output by hand as the console user to check privileges and result size
- Verify the cluster version supports the statement_statistics columns the query selects
Example fix
// before
if (stmtQueriesResponse.error) {
throw new Error(`Error while retrieving statements information: ${sqlApiErrorMessage(stmtQueriesResponse.error.message)}`);
}
// after: degrade instead of failing the whole insight when queries cannot be resolved
const stmtMaxSize = isMaxSizeError(stmtQueriesResponse.error?.message);
if (stmtQueriesResponse.error && !stmtMaxSize) {
getLogger().warn(`Error while resolving statement queries: ${sqlApiErrorMessage(stmtQueriesResponse.error.message)}`);
}
return buildTxnContentionInsightDetails(
contentionDetails,
txnsWithStmtFingerprints,
createStmtFingerprintToQueryMap(stmtQueriesResponse),
); Defensive patterns
Strategy: try-catch
Validate before calling
// Only request query strings for a bounded set of fingerprint ids
const ids = Array.from(stmtFingerprintIDs).slice(0, 500);
if (ids.length === 0) {
return buildTxnContentionInsightDetails(
contentionDetails,
txnsWithStmtFingerprints,
new Map(),
);
} Type guard
const hasSqlApiError = (
r: SqlExecutionResponse<unknown> | null,
): r is SqlExecutionResponse<unknown> & { error: SqlExecutionErrorMessage } =>
!!r?.error; Try / catch
try {
stmtQueriesResponse = await executeInternalSql<FingerprintStmtsResponseColumns>(
makeInsightsSqlRequest([fingerprintStmtsQuery(Array.from(stmtFingerprintIDs))]),
);
} catch (e) {
getLogger().warn(`Failed to resolve statement queries: ${e}`);
stmtQueriesResponse = null; // buildTxnContentionInsightDetails tolerates null
} Prevention
- Bound the fingerprint id list before querying
- Treat query-string resolution as best-effort: names can be dropped without losing the contention insight
- Monitor SQL API errors on crdb_internal.statement_statistics for permission drift
When it happens
Trigger: A contention insight where blocking txns resolved to at least one stmt fingerprint id, and the fingerprintStmtsQuery SQL API request returns an error (query failure, permission denial, gateway error, or oversized result).
Common situations: Same class as the txn-fingerprint step: very large statement statistics tables exceeding the SQL API result limit, console user without access to crdb_internal.statement_statistics, or version skew on the internal table schema during rolling upgrades.
Related errors
- Error while retrieving statements information: ${sqlApiError
- Error while retrieving insights information: ${sqlApiErrorMe
- Failed to collect execution details
- No schedule found with this ID.
- Error while ${errorMessageContext}: ${sqlApiErrorMessage(err
AI-assisted analysis of cockroachdb/cockroach@8812064a01 (2026-08-15).
Data as JSON: /api/errors/b4d16f4b25bc4ee0.
Report an issue: GitHub.