isUserQueryError tells the log/observability path whether a query failure is user-attributable (Info-level "Query execution failed.") or a real system error worth alerting on (Error-level "Query execution errored."). The discriminator is the SQLSTATE class — already computed via classifyErrorCode fo
(err error)
| 276 | // execution errored."). The discriminator is the SQLSTATE class — |
| 277 | // already computed via classifyErrorCode for the pgwire response. |
| 278 | // |
| 279 | // Cancellations (SQLSTATE 57014) are NOT short-circuited as user errors |
| 280 | // here. The call sites (logQueryError, the clientConn error paths) gate |
| 281 | // caller-driven cancellations upstream via clientConn.isCallerCancellation, |
| 282 | // so by the time isUserQueryError sees a cancel-shaped err the cancellation |
| 283 | // was infra-driven (gRPC client closed because the worker died, the worker |
| 284 | // was retired, etc.) and class 57 = operator intervention is the right |
| 285 | // bucket — that's a real failure we want surfaced at Error level. |
| 286 | func isUserQueryError(err error) bool { |
| 287 | if err == nil { |
| 288 | return false |
| 289 | } |
| 290 | return isUserQueryErrorCode(classifyErrorCode(err)) |
| 291 | } |