{"record":{"id":"2f45cd931eb94867","repo":"thanos-io/thanos","slug":"download-v","errorCode":null,"errorMessage":"download %v","messagePattern":"download (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools_bucket.go","lineNumber":1250,"sourceCode":"\t\t}\n\n\t\tif err := os.RemoveAll(tbc.tmpDir); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := os.MkdirAll(tbc.tmpDir, os.ModePerm); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tg.Add(func() error {\n\t\t\tchunkPool := chunkenc.NewPool()\n\t\t\tchangeLog := compactv2.NewChangeLog(io.Discard)\n\t\t\tstubCounter := promauto.With(nil).NewCounter(prometheus.CounterOpts{})\n\t\t\tfor _, id := range ids {\n\t\t\t\t// Delete series from block & modify.\n\t\t\t\tlevel.Info(logger).Log(\"msg\", \"downloading block\", \"source\", id)\n\t\t\t\tif err := block.Download(ctx, logger, insBkt, id, filepath.Join(tbc.tmpDir, id.String())); err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"download %v\", id)\n\t\t\t\t}\n\n\t\t\t\tmeta, err := metadata.ReadFromDir(filepath.Join(tbc.tmpDir, id.String()))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"read meta of %v\", id)\n\t\t\t\t}\n\t\t\t\tb, err := tsdb.OpenBlock(logutil.GoKitLogToSlog(logger), filepath.Join(tbc.tmpDir, id.String()), chunkPool, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"open block %v\", id)\n\t\t\t\t}\n\n\t\t\t\tp := compactv2.NewProgressLogger(logger, int(b.Meta().Stats.NumSeries))\n\t\t\t\tnewID := ulid.MustNew(ulid.Now(), rand.Reader)\n\t\t\t\tmeta.ULID = newID\n\t\t\t\tmeta.Thanos.Rewrites = append(meta.Thanos.Rewrites, metadata.Rewrite{\n\t\t\t\t\tSources:          meta.Compaction.Sources,\n\t\t\t\t\tDeletionsApplied: deletions,\n\t\t\t\t\tRelabelsApplied:  relabels,","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools_bucket.go#L1232-L1268","documentation":"Wraps an error from block.Download, which fetches the block's index/chunks/meta files from the object store into tmpDir during `tools bucket rewrite`. The error means the block's data could not be fully downloaded, either because it does not exist (deleted concurrently, wrong bucket), or due to an object store/network failure.","triggerScenarios":"Running rewrite when the block was deleted by compaction/garbage collection between listing and downloading; wrong bucket or credentials; transient network failure or object-store rate limiting during download.","commonSituations":"Rewriting an old block concurrently with a running compactor that removed it; misconfigured --objstore.prefix or bucket name pointing elsewhere; S3/GCS throttling; paused network connectivity in CI.","solutions":["Verify the block ID still exists with `thanos tools bucket ls` before rewriting and re-check after the failure.","Pause/drain the compactor for the bucket so it does not delete the block mid-rewrite.","Check object store connectivity/credentials and retry; check for rate-limit errors in the wrapped cause."],"exampleFix":"// before (compactor deleting concurrently)\nthanos tools bucket rewrite --objstore.bucket=b ID\n// after (run with compactor drained for the bucket)\nthanos tools bucket rewrite --objstore.bucket=b --consistent-delay ... ID # and no compactor running","handlingStrategy":"retry","validationCode":"// confirm block exists before rewrite\nthanos tools bucket ls --objstore.bucket=b | grep -q \"$ID\" || exit 1","typeGuard":null,"tryCatchPattern":"if err := block.Download(ctx, logger, bkt, id, dir); err != nil {\n    if errors.Is(err, context.Canceled) { return err }\n    level.Warn(logger).Log(\"msg\", \"download failed, retrying\", \"err\", err)\n    time.Sleep(backoff)\n}","preventionTips":["Pause the compactor while rewriting blocks","Retry transient object-store errors with backoff","Confirm bucket/credentials before long operations"],"tags":["network","thanos","object-store","download"],"backgroundTag":"resource-not-found","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"}