risingwavelabs/risingwave · error · PsqlError
Failed to run the query
Error message
Failed to run the query: {0} What it means
pgwire wraps errors raised while executing a simple-query (text protocol 'Q' message) into PsqlError::SimpleQueryError with this display message. The BoxedError source is the actual error from the frontend planner/executor (SQL syntax, permission, catalog errors, etc.).
Solutions
- Inspect the #[source] BoxedError for the concrete frontend error message.
- Fix the SQL statement reported by the source error (syntax, object names, permissions).
- Try the query via extended protocol/prepared statements to get richer error positioning if the message is unclear.
- Check frontend/meta service logs for the corresponding query execution error.
Example fix
// before: swallowing inner cause
Err(PsqlError::SimpleQueryError(e)) => error!("query failed");
// after: surface the source
Err(PsqlError::SimpleQueryError(e)) => error!("query failed: {e}; source: {:?}", e.source()); Defensive patterns
Strategy: try-catch
Validate before calling
// lint SQL with a parser before sending simple queries
let parsed = pg_query::parse(sql);
if parsed.is_err() { return Err("invalid SQL syntax"); } Type guard
fn is_simple_query_error(e: &PsqlError) -> bool { matches!(e, PsqlError::SimpleQueryError(_)) } Try / catch
match client.simple_query(sql).await {
Err(e) if is_simple_query_error(&e) => { log::error!("query failed: {e}; cause: {:?}", e.source()); surface_to_user(e); }
other => other,
} Prevention
- Validate SQL syntax and object names before execution.
- Grant required permissions to the connecting user up front.
- Split large multi-statement scripts so failures are attributable per statement.
When it happens
Trigger: A client sends a simple query via psql or any driver using the text protocol, and query planning or execution in the frontend returns an error (parse failure, unhandled statement type, runtime failure).
Common situations: SQL syntax errors; unsupported statements sent via simple protocol; permission/catalog errors (missing table); frontend panics or timeouts surfaced during execution.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- Failed to prepare the statement
- {0}
- {0}
- AFTER MATCH SKIP TO FIRST/LAST missing its target variable
- ALTER SINK_RATE_LIMIT is not for sink into table
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/6d1c1af27b013b01.
Report an issue: GitHub.
Appendix: source
Thrown at src/utils/pgwire/src/error.rs:44
pub enum PsqlError {
#[error("Failed to start a new session: {0}")]
StartupError(
#[source]
#[backtrace]
BoxedError,
),
#[error("Invalid password")]
PasswordError,
#[error("Protocol violation: {0}")]
ProtocolError(
#[source]
#[backtrace]
ProtocolViolationError,
),
#[error("Failed to run the query: {0}")]
SimpleQueryError(
#[source]
#[backtrace]
BoxedError,
),
#[error("Failed to prepare the statement: {0}")]
ExtendedPrepareError(
#[source]
#[backtrace]
BoxedError,
),
#[error("Failed to execute the statement: {0}")]
ExtendedExecuteError(
#[source]
#[backtrace]
BoxedError,View on GitHub (pinned to 6469eb736d)