{"record":{"id":"15f5edd6658a81a7","repo":"SigNoz/signoz","slug":"setttlv2-only-supported","errorCode":null,"errorMessage":"SetTTLV2 only supported","messagePattern":"SetTTLV2 only supported","errorType":"validation","errorClass":"model.ApiError","httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":930,"sourceCode":"\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})\n\thasCustomRetention, err := r.hasCustomRetentionColumn(ctx)\n\tif hasCustomRetention {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf(\"SetTTLV2 only supported\")}\n\t}\n\tif err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf(\"error in processing TTL\")}\n\t}\n\t// uuid is used as transaction id\n\tuuidWithHyphen := uuid.New()\n\tuuid := strings.Replace(uuidWithHyphen.String(), \"-\", \"\", -1)\n\n\tcoldStorageDuration := -1\n\tif len(params.ColdStorageVolume) > 0 {\n\t\tcoldStorageDuration = int(params.ToColdStorageDuration)\n\t}\n\n\ttableNameArray := []string{\n\t\tr.logsDB + \".\" + r.logsLocalTableV2,\n\t\tr.logsDB + \".\" + r.logsResourceLocalTableV2,\n\t\tgetLocalTableName(r.logsDB + \".\" + r.logsAttributeKeys),\n\t\tgetLocalTableName(r.logsDB + \".\" + r.logsResourceKeys),","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L912-L948","documentation":"ApiError (ErrorExec) from setTTLLogs when the logs table has a custom_retention column (hasCustomRetention == true). Legacy per-org TTL setting via this path is refused because the schema is on the newer custom-retention model where SetTTLV2 must be used instead.","triggerScenarios":"Invoking the logs TTL endpoint (SetTTL/setTTLLogs) against a SigNoz schema that has already migrated to custom retention — the guard clause returns immediately with 'SetTTLV2 only supported'.","commonSituations":"Older clients/automation still calling the v1 TTL API after the SigNoz upgrade added custom_retention; mixed versions during rolling upgrades.","solutions":["Switch the caller to the SetTTLV2 API for logs retention","Upgrade any scripts/UI to the v2 endpoints","If legacy behavior is truly required, consult migration docs rather than forcing v1"],"exampleFix":"// before\napiErr := reader.SetTTL(ctx, orgID, ttlParams) // legacy logs TTL\n\n// after\napiErr := reader.SetTTLV2(ctx, orgID, v2Params) // custom-retention schema","handlingStrategy":"type-guard","validationCode":"// Probe schema once and route to the right API\nhasV2, err := schemaHasCustomRetention(ctx, ch)\nif err != nil { return err }\nif hasV2 { return reader.SetTTLV2(ctx, orgID, v2Params) }\nreturn reader.SetTTL(ctx, orgID, v1Params)","typeGuard":"func requiresTTLV2(apiErr *model.ApiError) bool {\n    return apiErr != nil && strings.Contains(apiErr.Err.Error(), \"SetTTLV2 only supported\")\n}","tryCatchPattern":"apiErr := reader.SetTTL(ctx, orgID, params)\nif requiresTTLV2(apiErr) {\n    apiErr = reader.SetTTLV2(ctx, orgID, convertToV2(params))\n}","preventionTips":["Detect the custom-retention schema at integration time","Migrate retention automation to v2 endpoints during upgrades","Never assume v1 TTL works across schema migrations"],"tags":["ttl","retention","schema-migration","signoz"],"backgroundTag":"legacy-api-version-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}