{"record":{"id":"2869d240742184aa","repo":"googleapis/mcp-toolbox","slug":"errors-encountered-during-row-iteration-w-2869d2","errorCode":null,"errorMessage":"errors encountered during row iteration: %w","messagePattern":"errors encountered during row iteration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/oceanbase/oceanbase.go","lineNumber":154,"sourceCode":"\t\tvMap := make(map[string]any)\n\t\tfor i, name := range cols {\n\t\t\tval := rawValues[i]\n\t\t\tif val == nil {\n\t\t\t\tvMap[name] = nil\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// oceanbase uses mysql driver\n\t\t\tvMap[name], err = mysqlcommon.ConvertToType(colTypes[i], val)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"errors encountered when converting values: %w\", err)\n\t\t\t}\n\t\t}\n\t\tout = append(out, vMap)\n\t}\n\n\tif err := results.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"errors encountered during row iteration: %w\", err)\n\t}\n\n\treturn out, nil\n}\n\nfunc initOceanBaseConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname, queryTimeout string) (*sql.DB, error) {\n\t_, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\tdsn := fmt.Sprintf(\"%s:%s@tcp(%s:%s)/%s?parseTime=true\", user, pass, host, port, dbname)\n\n\tif queryTimeout != \"\" {\n\t\ttimeout, err := time.ParseDuration(queryTimeout)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid queryTimeout %q: %w\", queryTimeout, err)\n\t\t}\n\t\tdsn += \"&readTimeout=\" + timeout.String()\n\t}","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/oceanbase/oceanbase.go#L136-L172","documentation":"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.","triggerScenarios":"RunSQL iterates results.Next(); the underlying MySQL/OceanBase connection errors, times out, or is closed while rows are still being streamed.","commonSituations":"Long-running queries exceeding the readTimeout; server-side kill of the connection; network interruption during large result streaming.","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"],"exampleFix":"// before\ntoolbox --tools oceanbase_run_sql --query-timeout 30s\n// after\ntoolbox --tools oceanbase_run_sql --query-timeout 5m","handlingStrategy":"retry","validationCode":"// bound result size before streaming\nsql := baseSQL + \" LIMIT 10000\"","typeGuard":null,"tryCatchPattern":"out, err := src.RunSQL(ctx, sql)\nif err != nil && strings.Contains(err.Error(), \"row iteration\") {\n    // backoff then retry once\n    time.Sleep(time.Second)\n    out, err = src.RunSQL(ctx, sql)\n}","preventionTips":["Set generous queryTimeout/readTimeout for large results","Paginate large result sets","Monitor for server-side connection kills","Check network stability between toolbox and OceanBase"],"tags":["database","network","row-iteration","oceanbase"],"backgroundTag":"connection-lost-during-query","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}