{"record":{"id":"24f54d0e70ca486c","repo":"SigNoz/signoz","slug":"error-while-fetching-trace-schema-s","errorCode":null,"errorMessage":"error while fetching trace schema: %s","messagePattern":"error while fetching trace schema: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":4241,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unsupported aggregate operator\")\n\t}\n\tquery = fmt.Sprintf(\"SELECT DISTINCT(tag_key), tag_type, tag_data_type FROM %s.%s WHERE %s and tag_type != 'spanfield'\", r.TraceDB, r.spanAttributeTableV2, where)\n\tif req.Limit != 0 {\n\t\tquery = query + fmt.Sprintf(\" LIMIT %d;\", req.Limit)\n\t}\n\trows, err = r.db.Query(ctx, query, fmt.Sprintf(\"%%%s%%\", req.SearchText))\n\n\tif err != nil {\n\t\tr.logger.Error(\"Error while executing query\", errorsV2.Attr(err))\n\t\treturn nil, fmt.Errorf(\"error while executing query: %s\", err.Error())\n\t}\n\tdefer rows.Close()\n\n\tstatements := []model.ShowCreateTableStatement{}\n\tquery = fmt.Sprintf(\"SHOW CREATE TABLE %s.%s\", r.TraceDB, r.traceLocalTableName)\n\terr = r.db.Select(ctx, &statements, query)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error while fetching trace schema: %s\", err.Error())\n\t}\n\n\tvar tagKey string\n\tvar dataType string\n\tvar tagType string\n\tfor rows.Next() {\n\t\tif err := rows.Scan(&tagKey, &tagType, &dataType); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error while scanning rows: %s\", err.Error())\n\t\t}\n\t\tkey := v3.AttributeKey{\n\t\t\tKey:      tagKey,\n\t\t\tDataType: v3.AttributeKeyDataType(dataType),\n\t\t\tType:     v3.AttributeKeyType(tagType),\n\t\t\tIsColumn: isColumn(statements[0].Statement, tagType, tagKey, dataType),\n\t\t}\n\n\t\tif _, ok := constants.DeprecatedStaticFieldsTraces[tagKey]; !ok {\n\t\t\tresponse.AttributeKeys = append(response.AttributeKeys, key)","sourceCodeStart":4223,"sourceCodeEnd":4259,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L4223-L4259","documentation":"After successfully listing tag keys, the reader runs SHOW CREATE TABLE <tracesdb>.<traceLocalTableName> via db.Select into []model.ShowCreateTableStatement and that failed. The schema string is needed to compute the IsColumn flag for each attribute key, so the whole request fails.","triggerScenarios":"Calling GetAggregateAttribute on a distributed SigNoz setup where the local table (e.g. distributed_signoz_trace_spans / signoz_trace_spans_local) named by r.traceLocalTableName does not exist on the node being queried; insufficient permissions for SHOW CREATE TABLE; ClickHouse restarted mid-request dropping the connection.","commonSituations":"Config variable CH_LOCAL_EVENT_TABLE / traceLocalTableName set to a wrong name; a migration renamed the local table; user account lacks SHOW grant; older cluster where only the Distributed table exists with a different local name.","solutions":["Run SHOW CREATE TABLE <tracesdb>.<traceLocalTableName> manually as the query-service ClickHouse user to reproduce the exact error","Check the env/config value for the local trace table name and align it with the actual local table (SHOW TABLES FROM <tracesdb>)","Grant the ClickHouse user SHOW/SELECT privileges if the error is permission related","Update SigNoz so table naming matches the current schema migrations"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// startup check: verify the local trace table is visible\nrows, err := ch.Query(ctx, \"SHOW TABLES FROM \"+traceDB+\" LIKE '\"+localTable+\"'\")\nif err != nil || !rows.Next() {\n  log.Fatal(\"local trace table not found; check CH_LOCAL_EVENT_TABLE config\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n  if strings.Contains(err.Error(), \"error while fetching trace schema\") {\n    // schema lookup failed: check table existence/permissions, return 503 not 400\n  }\n}","preventionTips":["Validate traceLocalTableName config at service startup","Grant the ClickHouse user SHOW and SELECT on the traces database","Add a startup readiness probe that runs SHOW CREATE TABLE on required tables"],"tags":["clickhouse","show-create-table","schema","config","signoz"],"backgroundTag":"clickhouse-show-create-table-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}