{"record":{"id":"a0f2fa404e6a78d8","repo":"thanos-io/thanos","slug":"get-all-block-meta","errorCode":null,"errorMessage":"get all block meta.","messagePattern":"get all block meta\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/shipper/shipper.go","lineNumber":279,"sourceCode":"\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\n\t\tm, err := block.DownloadMeta(ctx, c.logger, c.bucket, id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !labels.Equal(labels.FromMap(m.Thanos.Labels), c.labels()) {\n\t\t\treturn nil\n\t\t}\n\n\t\tc.metas = append(c.metas, m.BlockMeta)\n\t\tc.lookupMetas[m.ULID] = struct{}{}\n\t\treturn nil\n\n\t}); err != nil {\n\t\treturn errors.Wrap(err, \"get all block meta.\")\n\t}\n\n\tc.synced = true\n\treturn nil\n}\n\nfunc (c *lazyOverlapChecker) IsOverlapping(ctx context.Context, newMeta tsdb.BlockMeta) error {\n\tif !c.synced {\n\t\tlevel.Info(c.logger).Log(\"msg\", \"gathering all existing blocks from the remote bucket for check\", \"id\", newMeta.ULID.String())\n\t\tif err := c.sync(ctx); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// TODO(bwplotka) so confusing! we need to sort it first. Add comment to TSDB code.\n\tmetas := append([]tsdb.BlockMeta{newMeta}, c.metas...)\n\tsort.Slice(metas, func(i, j int) bool {\n\t\treturn metas[i].MinTime < metas[j].MinTime","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/shipper/shipper.go#L261-L297","documentation":"Wraps any error encountered while the Syncer's meta sync scans the local TSDB directory and appends each block's metadata (via a bblock reader callback) into the in-memory meta list. It fires when reading/parsing a block meta.json under the shipper's directory fails (I/O error, corrupt/missing meta.json, invalid ULID directory name). The shipper needs a complete meta snapshot before it can decide overlaps or uploads, so a partial read aborts the whole sync setup.","triggerScenarios":"Calling Sync (or anything triggering checker sync, e.g. IsOverlapping on a non-synced checker) when a block directory under s.dir contains a corrupt or unreadable meta.json, or a directory walker I/O error occurs.","commonSituations":"Disk corruption or truncated meta.json after an unclean shutdown; manually copied block directories missing meta.json; permission problems on the TSDB dir; partially downloaded/deleted blocks while Prometheus is running.","solutions":["Inspect the wrapped cause in the error message and fix/restore the failing block's meta.json (re-copy the block or re-ingest it).","Run `thanos tools bucket verify` against the bucket and re-upload the affected block.","Remove the corrupt block directory from the local TSDB dir if its data is safely in object storage, then restart.","Check filesystem permissions and disk health (dmesg, mount rw) on the data directory."],"exampleFix":"// before\n// shipper fails at startup: get all block meta.: open /data/01ARZ3.../meta.json: no such file or directory\n// after\n// restore meta.json for the listed block or remove the corrupt block dir:\n// rm -rf /data/01ARZ3NDEKTSV4RRFFQ69G5FAV   # only if block already uploaded\n// then restart thanos sidecar","handlingStrategy":"validation","validationCode":"for _, b := range blockDirs {\n    if _, err := os.Stat(filepath.Join(b, \"meta.json\")); err != nil {\n        log.Printf(\"skipping block with missing meta.json: %s: %v\", b, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := shipper.Sync(ctx); err != nil {\n    if strings.Contains(err.Error(), \"get all block meta.\") {\n        log.Printf(\"corrupt local block meta, needs repair: %v\", err)\n    }\n}","preventionTips":["Use graceful shutdown for Prometheus to avoid truncated meta.json files","Monitor sidecar logs for block-scan warnings instead of waiting for sync failure","Never manually copy block directories without their meta.json","Run bucket verification periodically to detect corrupt blocks early"],"tags":["filesystem","block-meta","corruption","sidecar"],"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"}