SigNoz/signoz · error

error in processing sql query %w

Error message

error in processing sql query %w

What it means

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.

Source

Thrown at pkg/query-service/app/clickhouseReader/reader.go:909

			sum(total_count)/ @duration AS callRate,
			sum(error_count)/sum(total_count) * 100 as errorRate
		FROM %s.%s
		WHERE toUInt64(toDateTime(timestamp)) >= @start AND toUInt64(toDateTime(timestamp)) <= @end`,
		r.TraceDB, r.dependencyGraphTable,
	)

	tags := createTagQueryFromTagQueryParams(queryParams.Tags)
	filterQuery, filterArgs := services.BuildServiceMapQuery(tags, r.fl.BooleanOrEmpty(ctx, flagger.FeatureResolveSemconvFamilies, featuretypes.NewFlaggerEvaluationContext(orgID)))
	query += filterQuery + " GROUP BY src, dest;"
	args = append(args, filterArgs...)

	r.logger.Debug("GetDependencyGraph query", "query", query, "args", args)

	err := r.db.Select(ctx, &response, query, args...)

	if err != nil {
		r.logger.Error("Error in processing sql query", errorsV2.Attr(err))
		return nil, fmt.Errorf("error in processing sql query %w", err)
	}

	return &response, nil
}

func getLocalTableName(tableName string) string {

	tableNameSplit := strings.Split(tableName, ".")
	return tableNameSplit[0] + "." + strings.Split(tableNameSplit[1], "distributed_")[1]

}

func (r *ClickHouseReader) setTTLLogs(ctx context.Context, orgID string, params *retentiontypes.TTLParams) (*retentiontypes.SetTTLResponseItem, *model.ApiError) {
	ctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{
		instrumentationtypes.TelemetrySignal:  telemetrytypes.SignalLogs.StringValue(),
		instrumentationtypes.CodeNamespace:    "clickhouse-reader",
		instrumentationtypes.CodeFunctionName: "setTTLLogs",
	})

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Unwrap the error / check logs for the CH cause
  2. Ensure the dependencies table exists and rollups run
  3. Reduce the time range or shard the service-map query
  4. Scale ClickHouse resources and retry
Defensive patterns

Strategy: retry

Validate before calling

if !tableExists(ctx, ch, r.TraceDB, "distributed_dependency") {
    return fmt.Errorf("dependency table missing; rollups not initialized")
}

Type guard

func isWrappedChErr(err error) bool {
    var chErr *clickhouse.Error
    return errors.As(err, &chErr) || strings.Contains(err.Error(), "processing sql query")
}

Try / catch

graph, err := reader.GetDependencyGraph(ctx, params)
if err != nil && isWrappedChErr(err) {
    if transientCh(err) { graph, err = retryOnce(ctx, params) }
    if err != nil { return nil, fmt.Errorf("dep graph: %w", err) }
}

Prevention

When it happens

Trigger: 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.

Common situations: Fresh installs without the dependency-rollup tables, heavy time ranges on large trace volumes timing out, or CH resource exhaustion during service-map rendering.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/b4589dc8f39995c5. Report an issue: GitHub.