googleapis/mcp-toolbox · error
errors encountered during row iteration: %w
Error message
errors encountered during row iteration: %w
What it means
database/sql Rows.Err() reports any error that occurred during iteration over the result set (e.g. the connection dropped mid-scan). RunSQL surfaces it with this message after processing all rows.
Source
Thrown at internal/sources/oceanbase/oceanbase.go:154
vMap := make(map[string]any)
for i, name := range cols {
val := rawValues[i]
if val == nil {
vMap[name] = nil
continue
}
// oceanbase uses mysql driver
vMap[name], err = mysqlcommon.ConvertToType(colTypes[i], val)
if err != nil {
return nil, fmt.Errorf("errors encountered when converting values: %w", err)
}
}
out = append(out, vMap)
}
if err := results.Err(); err != nil {
return nil, fmt.Errorf("errors encountered during row iteration: %w", err)
}
return out, nil
}
func initOceanBaseConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname, queryTimeout string) (*sql.DB, error) {
_, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
defer span.End()
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?parseTime=true", user, pass, host, port, dbname)
if queryTimeout != "" {
timeout, err := time.ParseDuration(queryTimeout)
if err != nil {
return nil, fmt.Errorf("invalid queryTimeout %q: %w", queryTimeout, err)
}
dsn += "&readTimeout=" + timeout.String()
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Check the wrapped error for 'connection lost'/'invalid connection' and retry the query
- Increase the queryTimeout/readTimeout configuration
- Reduce result size (LIMIT, pagination) to shorten streaming time
- Verify network stability and server wait_timeout settings
Example fix
// before toolbox --tools oceanbase_run_sql --query-timeout 30s // after toolbox --tools oceanbase_run_sql --query-timeout 5m
Defensive patterns
Strategy: retry
Validate before calling
// bound result size before streaming sql := baseSQL + " LIMIT 10000"
Try / catch
out, err := src.RunSQL(ctx, sql)
if err != nil && strings.Contains(err.Error(), "row iteration") {
// backoff then retry once
time.Sleep(time.Second)
out, err = src.RunSQL(ctx, sql)
} Prevention
- Set generous queryTimeout/readTimeout for large results
- Paginate large result sets
- Monitor for server-side connection kills
- Check network stability between toolbox and OceanBase
When it happens
Trigger: RunSQL iterates results.Next(); the underlying MySQL/OceanBase connection errors, times out, or is closed while rows are still being streamed.
Common situations: Long-running queries exceeding the readTimeout; server-side kill of the connection; network interruption during large result streaming.
Related errors
- error iterating rows: %w
- unable to parse row: %w
- errors encountered when converting values: %w
- sql.Open: %w
- unable to connect to Oracle successfully: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/2869d240742184aa.
Report an issue: GitHub.