{"record":{"id":"d241a4b6f3bed2dd","repo":"thanos-io/thanos","slug":"read-meta-json-for-block-s","errorCode":null,"errorMessage":"read meta.json for block %s","messagePattern":"read meta\\.json for block (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/block.go","lineNumber":291,"sourceCode":"\t\tlevel.Debug(logger).Log(\"msg\", \"deleted file\", \"file\", name, \"bucket\", bkt.Name())\n\t\treturn nil\n\t})\n}\n\n// DownloadMeta downloads only meta file from bucket by block ID.\n// TODO(bwplotka): Differentiate between network error & partial upload.\nfunc DownloadMeta(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID) (metadata.Meta, error) {\n\trc, err := bkt.Get(ctx, path.Join(id.String(), MetaFilename))\n\tif err != nil {\n\t\treturn metadata.Meta{}, errors.Wrapf(err, \"meta.json bkt get for %s\", id.String())\n\t}\n\tdefer runutil.CloseWithLogOnErr(logger, rc, \"download meta bucket client\")\n\n\tvar m metadata.Meta\n\n\tobj, err := io.ReadAll(rc)\n\tif err != nil {\n\t\treturn metadata.Meta{}, errors.Wrapf(err, \"read meta.json for block %s\", id.String())\n\t}\n\n\tif err = json.Unmarshal(obj, &m); err != nil {\n\t\treturn metadata.Meta{}, errors.Wrapf(err, \"unmarshal meta.json for block %s\", id.String())\n\t}\n\n\treturn m, nil\n}\n\nfunc IsBlockMetaFile(path string) bool {\n\treturn filepath.Base(path) == MetaFilename\n}\n\nfunc IsBlockDir(path string) (id ulid.ULID, ok bool) {\n\tid, err := ulid.Parse(filepath.Base(path))\n\treturn id, err == nil\n}\n","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/block.go#L273-L309","documentation":"DownloadMeta in pkg/block/block.go fetches meta.json for a block from object storage and reads it fully. This error wraps any failure of io.ReadAll on the bucket reader — the HTTP/objstore read failed mid-stream (connection reset, timeout, cancellation). The ULID in the message identifies which block's meta.json could not be downloaded.","triggerScenarios":"bkt.Get(ctx, id/meta.json) succeeded in opening the reader but io.ReadAll(rc) returned an error — network interruption to object storage, context cancellation/deadline exceeded during transfer, or the object backend closing the connection prematurely.","commonSituations":"S3/GCS transient network blips; slow connection hitting the store-gateway or compactor request timeout; context cancelled by parent operation while downloading; misconfigured bucket causing stale/aborted HTTP connections.","solutions":["Retry the download; this is usually a transient network failure.","Verify ctx is not cancelled/timed out before or during the download.","Check object storage connectivity, credentials, and network egress from the pod/host.","Check object store server-side logs for aborted requests."],"exampleFix":"// before\nobj, err := io.ReadAll(rc)\nif err != nil {\n\treturn metadata.Meta{}, errors.Wrapf(err, \"read meta.json for block %s\", id.String())\n}\n// after\nobj, err := io.ReadAll(rc)\nif err != nil {\n\tif ctx.Err() != nil {\n\t\treturn metadata.Meta{}, errors.Wrapf(ctx.Err(), \"context done while reading meta.json for block %s\", id.String())\n\t}\n\treturn metadata.Meta{}, errors.Wrapf(err, \"read meta.json for block %s\", id.String())\n}","handlingStrategy":"retry","validationCode":"// caller side\nif err := ctx.Err(); err != nil {\n\treturn fmt.Errorf(\"context already cancelled before DownloadMeta(%s): %w\", id, err)\n}\nif exists, _ := bkt.Exists(ctx, path.Join(id.String(), metadata.MetaFilename)); !exists {\n\treturn fmt.Errorf(\"meta.json for block %s does not exist in bucket\", id)\n}","typeGuard":"func hasCtx(ctx context.Context) bool { return ctx != nil && ctx.Err() == nil }","tryCatchPattern":"m, err := block.DownloadMeta(ctx, logger, bkt, id)\nif err != nil {\n\tif ctx.Err() != nil { return err } // cancellation, do not retry\n\t// transient read failure: retry with backoff\n\treturn retry(ctx, func() error { _, err = block.DownloadMeta(ctx, logger, bkt, id); return err })\n}","preventionTips":["Always pass a non-cancelled context with an adequate deadline for downloads.","Wrap DownloadMeta in a bounded retry with backoff for transient object-store errors.","Monitor object storage latency/error rates; alert on sustained read failures.","Ensure stable network egress from compactor/store-gateway to the object store."],"tags":["object-storage","network","thanos"],"backgroundTag":"network-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"}