windmill-labs/windmill · error
Error executing query: {:?}
Error message
Error executing query: {:?} What it means
The MySQL executor streams query results; `conn.exec_iter(query, statement_values)` failed, so the stream yields this error instead of rows. It wraps the mysql_async error with debug formatting. The query never started executing (as opposed to failing mid-row, which is error 1046).
Source
Thrown at backend/windmill-worker/src/mysql_executor.rs:92
};
let result_f = async move {
if skip_collect {
conn.lock()
.await
.exec_drop(query, statement_values)
.await
.map_err(to_anyhow)?;
Ok(vec![])
} else if let Some(ref s3) = s3 {
let query = query.to_string();
let rows_stream = async_stream::stream! {
let mut conn = conn.lock().await;
let mut result = match conn.exec_iter(query, statement_values).await.map_err(to_anyhow) {
Ok(result) => result,
Err(e) => {
yield Err(anyhow!("Error executing query: {:?}", e));
return;
}
};
loop {
let row = result.next().await;
match row {
Ok(Some(row)) => {
yield Ok(convert_row_to_value(row));
}
Ok(None) => {
break;
}
Err(e) => {
yield Err(anyhow!("Error fetching row: {:?}", e));
return;
}
}
}View on GitHub (pinned to e474e8803c)
Solutions
- Read the wrapped mysql_async error for the SQLSTATE code (e.g. 1146 table missing, 1064 syntax, 2006 gone away).
- Fix the SQL in the script, or align it with the current schema.
- Check the MySQL resource (host, port, user, password, database) and test connectivity.
- If 'server has gone away', increase `wait_timeout`/`max_allowed_packet` on MySQL or enable connection ping/reconnect in the pool config.
- Grant the user the needed privileges on the target tables.
Example fix
// before SELECT form unexisting_table; // after SELECT * FROM existing_table; -- verify with SHOW TABLES first
Defensive patterns
Strategy: try-catch
Validate before calling
// validate SQL and connectivity before executing in the job // 1. test connection: mysql -h $HOST -P $PORT -u $USER -p -e 'select 1' $DB // 2. validate SQL: mysql ... -e "PREPARE stmt FROM 'SELECT * FROM my_table LIMIT 1'"
Try / catch
match result {
Ok(rows) => rows,
Err(e) => {
// inspect SQLSTATE to branch: 1064 syntax, 1146 missing table, 2006 gone away
return Err(anyhow!("mysql query failed: {e:?}"));
}
} Prevention
- Test the MySQL resource (host/port/creds) before wiring it into scripts
- Validate SQL against the real schema; watch for schema drift
- Enable pool connection ping or lower idle timeouts to avoid 'gone away' errors
- Grant the resource user only the privileges it needs — and at least those
When it happens
Trigger: `do_mysql_inner` executing a MySQL script resource query when the connection is dead/stale, SQL syntax is invalid, the referenced table/column doesn't exist, insufficient privileges, or a prepared-statement parameter type mismatches the column.
Common situations: MySQL server restarted between connection-pool creation and query (server has gone away); typos or schema drift in the SQL; user lacking SELECT on the target table; wrong port/db name in the MySQL resource; timeout `wait_timeout` reaping idle pooled connections.
Related errors
- SQL_PREPARATION_ERROR
- Error parsing sql
- Error fetching row: {:?}
- result.substring(__RESULT_ERR_PREFIX.length)
- Unimplemented case
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/3d8fa0eee94bb830.
Report an issue: GitHub.