{"record":{"id":"024a81410995aa76","repo":"googleapis/mcp-toolbox","slug":"errors-encountered-during-row-iteration-w-024a81","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/singlestore/singlestore.go","lineNumber":162,"sourceCode":"\t\t}\n\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\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 initSingleStoreConnectionPool(ctx context.Context, tracer trace.Tracer, cfg Config) (*sql.DB, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, cfg.Name)\n\tdefer span.End()\n\n\t// Build query parameters via url.Values for deterministic order and proper escaping.\n\tconnectionParams := url.Values{}\n\n\tmysqlCfg := mysql.Config{\n\t\tUser:                 cfg.User,\n\t\tPasswd:               cfg.Password,\n\t\tNet:                  \"tcp\",\n\t\tAddr:                 fmt.Sprintf(\"%s:%s\", cfg.Host, cfg.Port),","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/singlestore/singlestore.go#L144-L180","documentation":"RunSQL wraps results.Err() with this message after the row loop. results.Err() reports any error encountered during iteration that was not surfaced by Scan — most often the connection or result stream failed partway through reading rows, so the result set is incomplete and cannot be trusted.","triggerScenarios":"The result set iteration (results.Next()) terminated abnormally due to a lost connection, server abort, or read timeout after some rows were already processed.","commonSituations":"Very large result sets exceeding readTimeout, proxies/firewalls dropping long-lived connections mid-stream, server restarting during a query, or OOM kills on the SingleStore node for huge queries.","solutions":["Retry with a smaller result set (add LIMIT / pagination) to see if large streaming is the trigger.","Increase queryTimeout so the derived readTimeout accommodates the full result stream.","Check the wrapped driver error and SingleStore node logs for connection aborts.","Tune network intermediaries (LB idle timeouts) for long-running queries.","Enable TCP keepalives in connectionParams to keep idle streaming connections alive."],"exampleFix":"// before\n{\"statement\": \"SELECT * FROM huge_table\"}\n// after\n{\"statement\": \"SELECT * FROM huge_table LIMIT 1000\"}","handlingStrategy":"retry","validationCode":"// Prefer bounded queries for large tables\n// validation: check estimated size first\n// SELECT COUNT(*) FROM huge_table;  -- then add LIMIT if large","typeGuard":null,"tryCatchPattern":"out, err := source.RunSQL(ctx, stmt, params)\nif err != nil && strings.Contains(err.Error(), \"errors encountered during row iteration\") {\n    // stream aborted: retry with LIMIT/pagination\n    out, err = source.RunSQL(ctx, stmt+\" LIMIT 1000\", params)\n}","preventionTips":["Paginate large result sets with LIMIT/OFFSET or keyset pagination","Raise queryTimeout for big scans","Enable TCP keepalives via connectionParams","Raise LB idle timeouts beyond query duration"],"tags":["singlestore","sql","row-iteration","network"],"backgroundTag":"connection-lost-mid-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"}