{"record":{"id":"81e0200bbc2e258b","repo":"googleapis/mcp-toolbox","slug":"errors-encountered-during-query-execution-or-row-p-81e020","errorCode":null,"errorMessage":"errors encountered during query execution or row processing: %w","messagePattern":"errors encountered during query execution or row processing: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/oracle/oracle.go","lineNumber":256,"sourceCode":"\t\t\tcase *sql.RawBytes:\n\t\t\t\tif *v != nil {\n\t\t\t\t\tvar unmarshaledData any\n\t\t\t\t\tif err := json.Unmarshal(*v, &unmarshaledData); err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"unable to unmarshal json data for column %s\", col)\n\t\t\t\t\t}\n\t\t\t\t\tvMap[col] = unmarshaledData\n\t\t\t\t} else {\n\t\t\t\t\tvMap[col] = nil\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected receiver type: %T\", v)\n\t\t\t}\n\t\t}\n\t\tout = append(out, vMap)\n\t}\n\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"errors encountered during query execution or row processing: %w\", err)\n\t}\n\n\treturn out, nil\n}\n\nfunc buildGoOraConnString(user, password, connectStringBase, walletLocation string) string {\n\tuserInfo := url.UserPassword(\n\t\tdecodePercentEncodedUserInfo(user),\n\t\tdecodePercentEncodedUserInfo(password),\n\t).String()\n\n\tbase := fmt.Sprintf(\"oracle://%s@%s\", userInfo, connectStringBase)\n\ttrimmedWalletLocation := strings.TrimSpace(walletLocation)\n\tif trimmedWalletLocation == \"\" {\n\t\treturn base\n\t}\n\n\tq := url.Values{}","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/oracle/oracle.go#L238-L274","documentation":"This error wraps rows.Err() checked after the row-iteration loop in the Oracle read path. database/sql defers row-fetch errors to rows.Err(), so failures that occurred while pulling rows from the server (network drops, server-side cursor errors, context cancellation mid-iteration) surface only here, after all locally buffered rows were processed.","triggerScenarios":"RunSQL (readOnly=true) iterating a large result set when: the connection to Oracle drops mid-fetch (network reset, firewall idle timeout, session killed with ORA-00028), the context is canceled while rows stream, or the server raises an error partway through the cursor (e.g. ORA-01555 snapshot too old, temp/undo exhaustion).","commonSituations":"Large exports/queries exceeding Oracle undo retention (ORA-01555); result sets too big for one fetch window combined with unstable networks; long queries canceled by client-side context deadlines; DBA-killed sessions during heavy scans.","solutions":["Inspect the wrapped %w ORA- code: ORA-01555 means increase undo retention or fetch in batches; network errors need connectivity fixes.","Increase the context timeout passed to RunSQL if cancellation is the cause, or page the query with ROWNUM/OFFSET-FETCH limits.","Raise SQLNET.EXPIRE_TIME / keepalive and adjust firewall idle timeouts to survive long-running fetches.","For ORA-01555, reduce query runtime, fetch in smaller batches, or increase undo tablespace/retention.","Verify session stability: check for kill_session events or resource-manager limits if errors recur on long queries."],"exampleFix":"// before: one giant unbounded query\nSELECT * FROM huge_table;\n\n// after: batch with FETCH FIRST to keep each fetch window short\nSELECT * FROM huge_table ORDER BY id OFFSET :offset ROWS FETCH NEXT :batch ROWS ONLY;","handlingStrategy":"retry","validationCode":"ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)\ndefer cancel()\nif err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"connection unhealthy before long fetch: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"out, err := source.RunSQL(ctx, stmt, params, true)\nif err != nil {\n    if strings.Contains(err.Error(), \"errors encountered during query execution\") {\n        if isTransient(err) { // e.g. network reset, ORA-03113/03135\n            time.Sleep(backoff)\n            out, err = source.RunSQL(ctx, pagedStmt, params, true) // re-run with FETCH FIRST batching\n        }\n    }\n}\nif err != nil { return err }","preventionTips":["Page large result sets with ORDER BY + FETCH FIRST/OFFSET instead of one unbounded query.","Set SQLNET.EXPIRE_TIME and TCP keepalives for long-running fetches.","Size undo tablespace/retention for your longest queries to avoid ORA-01555.","Use contexts with timeouts slightly above expected query duration; log the wrapped ORA- code for diagnosis.","Keep queries idempotent (read-only) so retry after mid-fetch failure is safe."],"tags":["oracle","database-sql","rows-err","network","long-query"],"backgroundTag":"row-iteration-failed","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"}