googleapis/mcp-toolbox · error
errors encountered during query execution or row processing:
Error message
errors encountered during query execution or row processing: %w
What it means
This error is returned at the end of `RunSQL` when `results.Err()` reports a deferred error from row iteration or query execution. Unlike the immediate execution error, this catches failures that occur mid-stream — connection dropped while reading rows, context cancellation during iteration, or driver-level stream errors.
Source
Thrown at internal/sources/mssql/mssql.go:149
}
for results.Next() {
scanErr := results.Scan(values...)
if scanErr != nil {
return nil, fmt.Errorf("unable to parse row: %w", scanErr)
}
row := orderedmap.Row{}
for i, name := range cols {
row.Add(name, rawValues[i])
}
out = append(out, row)
}
}
// Check for errors from iterating over rows or from the query execution itself.
// results.Close() is handled by defer.
if err := results.Err(); err != nil {
return nil, fmt.Errorf("errors encountered during query execution or row processing: %w", err)
}
return out, nil
}
func initMssqlConnection(
ctx context.Context,
tracer trace.Tracer,
name, host, port, user, pass, dbname, encrypt string,
) (
*sql.DB,
error,
) {
//nolint:all // Reassigned ctx
ctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
defer span.End()
userAgent, err := util.UserAgentFromContext(ctx)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Unwrap the error and check for context.DeadlineExceeded / connection reset causes
- Increase the context timeout or paginate large result sets (OFFSET/FETCH)
- Enable connection retry/resilience (connection pool settings)
- Check network stability and server logs for dropped connections
Example fix
// before (one huge query) stmt := "SELECT * FROM big_table" // after (paginated) stmt := "SELECT * FROM big_table ORDER BY id OFFSET 0 ROWS FETCH NEXT 10000 ROWS ONLY"
Defensive patterns
Strategy: retry
Type guard
func isTransientStreamErr(err error) bool {
return errors.Is(err, context.DeadlineExceeded) ||
errors.Is(err, io.ErrUnexpectedEOF) ||
errors.Is(err, syscall.ECONNRESET)
} Try / catch
res, err := src.RunSQL(ctx, stmt, nil)
if err != nil && strings.Contains(err.Error(), "row processing") {
if errors.Is(err, context.DeadlineExceeded) {
ctx2, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
res, err = src.RunSQL(ctx2, stmt, nil)
}
} Prevention
- Size context timeouts to query duration
- Paginate large result sets
- Enable TCP keepalives
- Handle upstream context cancellation gracefully
When it happens
Trigger: Calling RunSQL when the connection drops partway through reading a large result set; context is cancelled while rows are still streaming; driver-level network errors during rows.Next() iteration.
Common situations: Timeouts on large SELECTs; network instability between client and SQL Server; server closing the connection (idle kill, failover) mid-result; context cancelled by an upstream request timeout.
Related errors
- errors encountered during row iteration: %w
- failed to fetch OIDC config: %w
- unable to execute query: %w
- unable to parse row: %w
- errors encountered during query execution or row processing:
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/edcec6bc0caa4198.
Report an issue: GitHub.