{"record":{"id":"3d4a2c50b3418d6f","repo":"thanos-io/thanos","slug":"read-file-s","errorCode":null,"errorMessage":"read file: %s","messagePattern":"read file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/metadata/markers.go","lineNumber":132,"sourceCode":"}\n\nfunc (n *NoDownsampleMark) markerFilename() string { return NoDownsampleMarkFilename }\n\n// ReadMarker reads the given mark file from <dir>/<marker filename>.json in bucket.\nfunc ReadMarker(ctx context.Context, logger log.Logger, bkt objstore.InstrumentedBucketReader, dir string, marker Marker) error {\n\tmarkerFile := path.Join(dir, marker.markerFilename())\n\tr, err := bkt.ReaderWithExpectedErrs(bkt.IsObjNotFoundErr).Get(ctx, markerFile)\n\tif err != nil {\n\t\tif bkt.IsObjNotFoundErr(err) {\n\t\t\treturn ErrorMarkerNotFound\n\t\t}\n\t\treturn errors.Wrapf(err, \"get file: %s\", markerFile)\n\t}\n\tdefer runutil.CloseWithLogOnErr(logger, r, \"close bkt marker reader\")\n\n\tmetaContent, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"read file: %s\", markerFile)\n\t}\n\n\tif err := json.Unmarshal(metaContent, marker); err != nil {\n\t\treturn errors.Wrapf(ErrorUnmarshalMarker, \"file: %s; err: %v\", markerFile, err.Error())\n\t}\n\tswitch marker.markerFilename() {\n\tcase NoCompactMarkFilename:\n\t\tif version := marker.(*NoCompactMark).Version; version != NoCompactMarkVersion1 {\n\t\t\treturn errors.Errorf(\"unexpected no-compact-mark file version %d, expected %d\", version, NoCompactMarkVersion1)\n\t\t}\n\tcase NoDownsampleMarkFilename:\n\t\tif version := marker.(*NoDownsampleMark).Version; version != NoDownsampleMarkVersion1 {\n\t\t\treturn errors.Errorf(\"unexpected no-downsample-mark file version %d, expected %d\", version, NoDownsampleMarkVersion1)\n\t\t}\n\tcase DeletionMarkFilename:\n\t\tif version := marker.(*DeletionMark).Version; version != DeletionMarkVersion1 {\n\t\t\treturn errors.Errorf(\"unexpected deletion-mark file version %d, expected %d\", version, DeletionMarkVersion1)\n\t\t}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/metadata/markers.go#L114-L150","documentation":"Inside metadata.ReadMarker, when io.ReadAll fails while draining the marker file's reader, the error is wrapped with \"read file: <path>\". The Get succeeded but streaming the marker bytes from the object storage failed mid-read.","triggerScenarios":"ReadMarker obtains a bucket reader successfully, then io.ReadAll(r) errors due to connection reset/timeout while streaming, TLS termination, or an underlying reader that fails partway through the download.","commonSituations":"Flaky network between the client and S3/GCS/Azure; long-running fetcher operations hitting idle connection timeouts; proxies or load balancers cutting connections mid-body.","solutions":["Retry the read — this is usually a transient network failure; consider bucket client retry settings.","Check network stability/proxy timeouts between the client and object storage.","Inspect the wrapped cause for the provider-specific error and tune the bucket client (timeouts, max idle conns)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := metadata.ReadMarker(ctx, logger, bkt, id, mark); err != nil {\n\tif strings.Contains(err.Error(), \"read file:\") {\n\t\t// transient stream failure: retry with backoff\n\t\treturn retry(ctx, func() error { return metadata.ReadMarker(ctx, logger, bkt, id, mark) })\n\t}\n\treturn err\n}","preventionTips":["Configure the bucket client with sane timeouts and connection reuse to avoid mid-body disconnects.","Run bulk operations over stable network paths; avoid aggressive proxy idle timeouts.","Prefer small marker files and retry-on-transient patterns around ReadMarker."],"tags":["object-storage","io","network","wrapped-error"],"backgroundTag":"file-read-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"}