{"record":{"id":"b4589dc8f39995c5","repo":"SigNoz/signoz","slug":"error-in-processing-sql-query-w","errorCode":null,"errorMessage":"error in processing sql query %w","messagePattern":"error in processing sql query %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":909,"sourceCode":"\t\t\tsum(total_count)/ @duration AS callRate,\n\t\t\tsum(error_count)/sum(total_count) * 100 as errorRate\n\t\tFROM %s.%s\n\t\tWHERE toUInt64(toDateTime(timestamp)) >= @start AND toUInt64(toDateTime(timestamp)) <= @end`,\n\t\tr.TraceDB, r.dependencyGraphTable,\n\t)\n\n\ttags := createTagQueryFromTagQueryParams(queryParams.Tags)\n\tfilterQuery, filterArgs := services.BuildServiceMapQuery(tags, r.fl.BooleanOrEmpty(ctx, flagger.FeatureResolveSemconvFamilies, featuretypes.NewFlaggerEvaluationContext(orgID)))\n\tquery += filterQuery + \" GROUP BY src, dest;\"\n\targs = append(args, filterArgs...)\n\n\tr.logger.Debug(\"GetDependencyGraph query\", \"query\", query, \"args\", args)\n\n\terr := r.db.Select(ctx, &response, query, args...)\n\n\tif err != nil {\n\t\tr.logger.Error(\"Error in processing sql query\", errorsV2.Attr(err))\n\t\treturn nil, fmt.Errorf(\"error in processing sql query %w\", err)\n\t}\n\n\treturn &response, nil\n}\n\nfunc getLocalTableName(tableName string) string {\n\n\ttableNameSplit := strings.Split(tableName, \".\")\n\treturn tableNameSplit[0] + \".\" + strings.Split(tableNameSplit[1], \"distributed_\")[1]\n\n}\n\nfunc (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, params *retentiontypes.TTLParams) (*retentiontypes.SetTTLResponseItem, *model.ApiError) {\n\tctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{\n\t\tinstrumentationtypes.TelemetrySignal:  telemetrytypes.SignalLogs.StringValue(),\n\t\tinstrumentationtypes.CodeNamespace:    \"clickhouse-reader\",\n\t\tinstrumentationtypes.CodeFunctionName: \"setTTLLogs\",\n\t})","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L891-L927","documentation":"Wrapped error from GetDependencyGraph when the Select for dependency-graph edges fails. This one preserves the cause with %w, so callers can inspect errors.Unwrap for the real ClickHouse failure.","triggerScenarios":"Calling the dependency-graph API (service map) when the dependencies query fails: missing dependencies table in SIGNOZ_TRACES_DB, CH timeout on large aggregations, or connection errors.","commonSituations":"Fresh installs without the dependency-rollup tables, heavy time ranges on large trace volumes timing out, or CH resource exhaustion during service-map rendering.","solutions":["Unwrap the error / check logs for the CH cause","Ensure the dependencies table exists and rollups run","Reduce the time range or shard the service-map query","Scale ClickHouse resources and retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if !tableExists(ctx, ch, r.TraceDB, \"distributed_dependency\") {\n    return fmt.Errorf(\"dependency table missing; rollups not initialized\")\n}","typeGuard":"func isWrappedChErr(err error) bool {\n    var chErr *clickhouse.Error\n    return errors.As(err, &chErr) || strings.Contains(err.Error(), \"processing sql query\")\n}","tryCatchPattern":"graph, err := reader.GetDependencyGraph(ctx, params)\nif err != nil && isWrappedChErr(err) {\n    if transientCh(err) { graph, err = retryOnce(ctx, params) }\n    if err != nil { return nil, fmt.Errorf(\"dep graph: %w\", err) }\n}","preventionTips":["Ensure dependency rollup jobs run before serving service maps","Unwrap %w errors to classify retryability","Narrow time windows for service maps on large datasets"],"tags":["clickhouse","service-map","dependency-graph","database"],"backgroundTag":"database-query-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}