{"record":{"id":"7e73952ec7c7637a","repo":"jaegertracing/jaeger","slug":"failed-to-query-dependencies-w","errorCode":null,"errorMessage":"failed to query dependencies: %w","messagePattern":"failed to query dependencies: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/depstore/reader.go","lineNumber":37,"sourceCode":"\ntype Reader struct {\n\tconn driver.Conn\n}\n\nfunc NewDependencyReader(conn driver.Conn) *Reader {\n\treturn &Reader{conn: conn}\n}\n\n// dependencyKey groups dependency links by (parent, child) for merging.\ntype dependencyKey struct {\n\tparent string\n\tchild  string\n}\n\nfunc (r *Reader) GetDependencies(ctx context.Context, query depstore.QueryParameters) ([]model.DependencyLink, error) {\n\trows, err := r.conn.Query(ctx, sql.SelectDependencies, query.StartTime, query.EndTime)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to query dependencies: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\t// Merge dependencies from all snapshots in the time range.\n\tmerged := make(map[dependencyKey]uint64)\n\n\tfor rows.Next() {\n\t\tvar blob string\n\t\tif err := rows.Scan(&blob); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to scan dependency row: %w\", err)\n\t\t}\n\t\tvar links []dependencyLink\n\t\tif err := json.Unmarshal([]byte(blob), &links); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to unmarshal dependencies JSON: %w\", err)\n\t\t}\n\t\tfor _, link := range links {\n\t\t\tmerged[dependencyKey{link.Parent, link.Child}] += link.CallCount\n\t\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/depstore/reader.go#L19-L55","documentation":"ClickHouse depstore Reader.GetDependencies queries the jaeger_dependencies table for dependency-link snapshots between the query's start and end times. If the underlying clickhouse-go Query call fails — connection errors, DNS failure, auth rejection, malformed SQL/table missing — the error is wrapped with this message and returned. The %w wrap preserves the driver error for errors.Is/As inspection.","triggerScenarios":"Calling GetDependencies(ctx, depstore.QueryParameters{StartTime, EndTime}) when r.conn.Query(ctx, sql.SelectDependencies, ...) returns an error: server unreachable, credentials invalid, database/table absent, context canceled before the query starts.","commonSituations":"ClickHouse endpoint misconfigured in the storage config; ClickHouse down or restarting; wrong username/password or TLS settings; network policy blocking port 9000/8123; table not created by schema initialization.","solutions":["Verify ClickHouse connectivity (address, port, credentials, TLS) in the storage configuration and that the server is up.","Confirm the schema is initialized (jaeger_dependencies table exists) with the correct database name.","Inspect the wrapped driver error via errors.Is/As (e.g. clickhouse exceptions) to pinpoint auth vs network vs SQL causes; check context deadlines."],"exampleFix":"// config before\nstorage: { clickhouse: { address: \"clickhouse:9009\" } }\n// after (default native port)\nstorage: { clickhouse: { address: \"clickhouse:9000\", database: \"jaeger\" } }","handlingStrategy":"try-catch","validationCode":"if err := conn.Ping(ctx); err != nil {\n  return fmt.Errorf(\"clickhouse unreachable: %w\", err)\n}\nif query.StartTime.After(query.EndTime) {\n  return errors.New(\"invalid dependency query range\")\n}","typeGuard":null,"tryCatchPattern":"deps, err := reader.GetDependencies(ctx, q)\nif err != nil {\n  var chEx *clickhouse.Exception\n  if errors.As(err, &chEx) {\n    log.Printf(\"clickhouse error code=%d: %v\", chEx.Code, chEx)\n  } else if errors.Is(err, context.DeadlineExceeded) {\n    log.Printf(\"dependency query timed out\")\n  }\n  return fmt.Errorf(\"getting dependencies: %w\", err)\n}","preventionTips":["Validate ClickHouse address/credentials/TLS in config and monitor connectivity (ping/healthcheck)","Ensure the schema job created the dependencies table before serving traffic","Set sane query timeouts and inspect wrapped clickhouse.Exception codes when errors occur"],"tags":["clickhouse","dependency-store","query-failure","database"],"backgroundTag":"database-query-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}