{"record":{"id":"00132ad7ac0ae243","repo":"googleapis/mcp-toolbox","slug":"failed-to-execute-scylladb-query-w","errorCode":null,"errorMessage":"failed to execute ScyllaDB query: %w","messagePattern":"failed to execute ScyllaDB query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/scylladb/scylladb.go","lineNumber":129,"sourceCode":"\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params parameters.ParamValues) (any, error) {\n\tsliceParams := params.AsSlice()\n\titer := s.ScyllaDBSession().Query(statement, sliceParams...).WithContext(ctx).Iter()\n\n\t// Create a slice to store the output\n\tvar out []map[string]interface{}\n\n\t// Scan results into a map and append to the slice\n\tfor {\n\t\trow := make(map[string]interface{}) // Create a new map for each row\n\t\tif !iter.MapScan(row) {\n\t\t\tbreak // No more rows\n\t\t}\n\t\tout = append(out, row)\n\t}\n\n\tif err := iter.Close(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute ScyllaDB query: %w\", err)\n\t}\n\treturn out, nil\n}\n\nvar _ sources.Source = &Source{}\n\nfunc initScyllaDBSession(ctx context.Context, tracer trace.Tracer, c Config) (*gocql.Session, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, c.Name)\n\tdefer span.End()\n\n\t// Validate authentication configuration\n\tif c.Password != \"\" && c.Username == \"\" {\n\t\treturn nil, fmt.Errorf(\"invalid ScyllaDB configuration: password provided without a username\")\n\t}\n\n\tcluster := gocql.NewCluster(c.Hosts...)\n\tcluster.ProtoVersion = c.ProtoVersion","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/scylladb/scylladb.go#L111-L147","documentation":"RunSQL executes a CQL query and iterates the result scanner. When the iterator is closed, iter.Close() returns any deferred error encountered while paging rows (driver-level or cluster-level errors); the toolbox wraps it as 'failed to execute ScyllaDB query'. This means the query started but failed partway through fetching results.","triggerScenarios":"A SELECT/executed via session.Query(...).Iter() begins returning rows, then a paging error occurs: node down mid-iteration, coordinator timeout, consistency not achieved, or the connection dropped. iter.Close() surfaces that error and RunSQL wraps it.","commonSituations":"Large result sets spanning multiple pages hitting node failures/timeouts; query timeouts on big scans; node restarts during iteration; tombstone-heavy scans triggering ReadTimeout; TLS/connection drops.","solutions":["Read the wrapped error: ReadTimeout/WriteTimeout → tune `timeout` in the source config or narrow the query with WHERE/LIMIT.","If a node died mid-query, retry the query; consider lowering `pageSize` to reduce per-page latency.","Check statement-level consistency; lower ONE/LOCAL_ONE if consistency failures occur during topology changes.","Add keys/indexes to avoid full-table scans with huge tombstones.","Verify cluster health (`nodetool status`) and retry transient failures with backoff."],"exampleFix":"// before (client)\nrows, err := tool.Invoke(ctx, {\"sql\": \"SELECT * FROM events\"})\n// after — narrow the query and page\nrows, err := tool.Invoke(ctx, {\"sql\": \"SELECT * FROM events WHERE day = '2026-09-04' LIMIT 1000\"})","handlingStrategy":"retry","validationCode":"// Avoid unbounded scans that fail mid-iteration\n// Validate the query has a LIMIT or partition-key WHERE clause before invoking\nif (!/\\bLIMIT\\b/i.test(sql) && !/\\bWHERE\\b/i.test(sql)) {\n  throw new Error('query must include LIMIT or a WHERE clause');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await invokeTool('scylladb_run_sql', { sql });\n} catch (e) {\n  if (/timeout|unavailable|Stream/i.test(e.message)) {\n    await sleep(1000); // retry once with backoff; consider narrower query\n    return invokeTool('scylladb_run_sql', { sql });\n  }\n  throw e;\n}","preventionTips":["Always bound large queries with LIMIT/partition-key filters.","Tune the source's timeout for heavy scans.","Check nodetool status during topology changes; delay big queries until stable.","Keep pageSize modest so each page completes quickly."],"tags":["scylladb","cql","query","go"],"backgroundTag":"query-execution-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"}