{"record":{"id":"0d6b9203f8727755","repo":"googleapis/mcp-toolbox","slug":"errors-encountered-during-row-iteration-w-0d6b92","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/mysql/mysql.go","lineNumber":180,"sourceCode":"\t\trow := orderedmap.Row{}\n\t\tfor i, name := range cols {\n\t\t\tval := rawValues[i]\n\t\t\tif val == nil {\n\t\t\t\trow.Add(name, nil)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconvertedValue, 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\trow.Add(name, convertedValue)\n\t\t}\n\t\tout = append(out, row)\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 initMySQLConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname, queryTimeout string, queryParams map[string]string) (*sql.DB, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\tconfig := driver.NewConfig()\n\tconfig.Addr = fmt.Sprintf(\"%s:%s\", host, port)\n\tconfig.Net = \"tcp\"\n\tif user != \"\" {\n\t\tconfig.User = user\n\t\t// password will require user\n\t\tif pass != \"\" {\n\t\t\tconfig.Passwd = pass","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/mysql/mysql.go#L162-L198","documentation":"This error wraps the result of rows.Err() after the row loop in the MySQL RunSQL tool. It signals that the result-set iteration ended abnormally — the underlying connection experienced an error mid-stream (network drop, server killed the connection, context canceled) rather than reaching a clean end of rows.","triggerScenarios":"A large result set iteration interrupted by a network interruption, a MySQL server timeout (wait_timeout, net_write_timeout), the query context being canceled, or the server closing the connection while rows were still streaming.","commonSituations":"Long-running queries over flaky networks, results larger than available memory/buffers behind proxies (e.g. Cloud SQL proxy, load balancers with idle timeouts), and Docker/NAT connections reaped mid-query.","solutions":["Re-run the query; transient network drops often succeed on retry.","Reduce result set size with LIMIT/pagination so rows stream within connection timeouts.","Increase relevant timeouts (server net_read_timeout/net_write_timeout, client ReadTimeout, proxy idle timeouts).","Check server logs for aborted connections and enable TCP keepalives in the DSN (e.g. timeout/readTimeout params)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var out any\nerr := retry.Do(func() error {\n    var invokeErr error\n    out, invokeErr = toolboxClient.InvokeTool(ctx, \"run-sql\", params)\n    if invokeErr != nil && strings.Contains(invokeErr.Error(), \"errors encountered during row iteration\") {\n        return invokeErr // transient network/stream error: retry\n    }\n    return nil // do not retry other errors\n}, retry.Attempts(3), retry.Delay(2*time.Second), retry.OnRetry(func(n uint, err error) {\n    log.Printf(\"row iteration interrupted, retry %d: %v\", n+1, err)\n}))","preventionTips":["Paginate large results with LIMIT/OFFSET or keyset pagination instead of streaming huge sets.","Keep TCP keepalives and idle timeouts above the longest expected query duration (client, server, and any proxy).","Use retry with backoff for read-only queries; transient connection drops are common.","Monitor server aborted_connections counters to distinguish client-side vs server-side kills."],"tags":["mysql","network","sql","streaming"],"backgroundTag":"connection-reset-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"}