{"record":{"id":"4ebbf45c72120167","repo":"thanos-io/thanos","slug":"sync-before-retention","errorCode":null,"errorMessage":"sync before retention","messagePattern":"sync before retention","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/compact.go","lineNumber":519,"sourceCode":"\t\t\t\tinsBkt,\n\t\t\t\tfilteredMetas,\n\t\t\t\tdownsamplingDir,\n\t\t\t\tconf.downsampleConcurrency,\n\t\t\t\tconf.blockFilesConcurrency,\n\t\t\t\tmetadata.HashFunc(conf.hashFunc),\n\t\t\t\tconf.acceptMalformedIndex,\n\t\t\t); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"second pass of downsampling failed\")\n\t\t\t}\n\n\t\t\tlevel.Info(logger).Log(\"msg\", \"downsampling iterations done\")\n\t\t} else {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"downsampling was explicitly disabled\")\n\t\t}\n\n\t\t// TODO(bwplotka): Find a way to avoid syncing if no op was done.\n\t\tif err := sy.SyncMetas(ctx); err != nil {\n\t\t\treturn errors.Wrap(err, \"sync before retention\")\n\t\t}\n\n\t\tif err := compact.ApplyRetentionPolicyByResolution(ctx, logger, insBkt, sy.Metas(), retentionByResolution, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, \"\")); err != nil {\n\t\t\treturn errors.Wrap(err, \"retention failed\")\n\t\t}\n\n\t\treturn cleanPartialMarked()\n\t}\n\n\tg.Add(func() error {\n\t\tdefer runutil.CloseWithLogOnErr(logger, insBkt, \"bucket client\")\n\n\t\tif !conf.wait {\n\t\t\treturn compactMainFn()\n\t\t}\n\n\t\t// --wait=true is specified.\n\t\treturn runutil.Repeat(conf.waitInterval, ctx.Done(), func() error {","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/compact.go#L501-L537","documentation":"Wrapper error in runCompact (cmd/thanos/compact.go:519) around sy.SyncMetas(ctx) before applying retention. Retention decisions need an up-to-date view of bucket metas; the sync failure aborts the compaction cycle.","triggerScenarios":"sy.SyncMetas(ctx) error after compaction/downsampling: object store list/get failures, throttling, network interruption, corrupt meta objects.","commonSituations":"Long-running compaction cycles exceeding object-store credential lifetimes; transient bucket outages; rate limiting on very large buckets.","solutions":["Check the wrapped inner error for the failing store call","Retry the run — retention will re-run on next cycle","Validate credentials/TTL for long-running processes","Add retry/backoff and timeouts to the bucket client configuration","Monitor object-store error metrics correlated with compaction runs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := sy.SyncMetas(ctx); err != nil {\n\tif errors.Is(err, context.Canceled) { return err }\n\treturn errors.Wrap(err, \"sync before retention\")\n}","preventionTips":["Use credentials that outlast the entire compaction cycle","Enable client-side retry with exponential backoff","Monitor sync latency/errors as a leading indicator"],"tags":["thanos","object-storage","sync","retention"],"backgroundTag":"http-request-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}