{"record":{"id":"5ac8010c1f3cef95","repo":"SigNoz/signoz","slug":"internal-5ac801","errorCode":"internal","errorMessage":"load ttl_setting rows for org %q table %q","messagePattern":"load ttl_setting rows for org %q table %q","errorType":"error_code","errorClass":"errors.base","httpStatus":500,"severity":"error","filePath":"pkg/modules/retention/implretention/store.go","lineNumber":37,"sourceCode":"\treturn &store{sqlstore: sqlstore}\n}\n\n// ListTTLSettingsByTableNameAndBeforeCreatedAt returns successful TTL settings before the given timestamp.\nfunc (store *store) ListTTLSettingsByTableNameAndBeforeCreatedAt(ctx context.Context, orgID valuer.UUID, tableName string, beforeMs int64) ([]*retentiontypes.TTLSetting, error) {\n\trows := []*retentiontypes.TTLSetting{}\n\terr := store.\n\t\tsqlstore.\n\t\tBunDB().\n\t\tNewSelect().\n\t\tModel(&rows).\n\t\tWhere(\"table_name = ?\", tableName).\n\t\tWhere(\"org_id = ?\", orgID.StringValue()).\n\t\tWhere(\"status = ?\", retentiontypes.TTLSettingStatusSuccess).\n\t\tWhere(\"created_at < ?\", time.UnixMilli(beforeMs).UTC()).\n\t\tOrderExpr(\"created_at ASC\").\n\t\tScan(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, \"load ttl_setting rows for org %q table %q\", orgID.StringValue(), tableName)\n\t}\n\n\treturn rows, nil\n}\n","sourceCodeStart":19,"sourceCodeEnd":42,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/modules/retention/implretention/store.go#L19-L42","documentation":"The retention store's ListTTLSettingsByTableNameAndBeforeCreatedAt query (org_id + status=success + created_at < beforeMs, ordered ASC) failed at the database and is wrapped as an internal error naming the org and table. Used by GetRetentionPolicySegments to load completed TTL settings for compaction/retention processing.","triggerScenarios":"Running retention policy segment computation when the ttl_setting table is missing/corrupted, the DB is unreachable, or the created_at/org_id/status columns have schema drift; also possible query timeouts on large tables.","commonSituations":"Failed or skipped migration creating ttl_setting, Postgres outage, version upgrade changing the ttl_setting schema, heavy table without expected indexes causing timeouts.","solutions":["Check the wrapped driver error in logs for the real cause (connection, missing relation, timeout)","Verify the ttl_setting table and its org_id/status/created_at columns exist","Apply pending migrations and confirm indexes on (org_id, status, created_at)","Retry after DB health is restored; investigate slow queries if it is a timeout"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { segments = await getRetentionPolicySegments(orgID, tableName, beforeMs); } catch (e) { if (e.type === 'internal' && /load ttl_setting rows/i.test(e.message)) { await sleep(backoff()); segments = await getRetentionPolicySegments(orgID, tableName, beforeMs); } else throw e; }","preventionTips":["Ensure migrations for ttl_setting run before enabling retention jobs","Index ttl_setting(org_id, status, created_at) to avoid timeouts","Alert on retention job failures and page on repeated internal errors"],"tags":["database","retention","ttl","internal-error","golang"],"backgroundTag":"database-query-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}