{"record":{"id":"afd98053d0666049","repo":"thanos-io/thanos","slug":"read-meta-file-afd980","errorCode":null,"errorMessage":"read meta file","messagePattern":"read meta file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/shipper/shipper.go","lineNumber":321,"sourceCode":"\treturn nil\n}\n\nfunc (s *Shipper) AreAllBlocksUploaded() (bool, error) {\n\ts.mtx.RLock()\n\tdefer s.mtx.RUnlock()\n\n\tmetas, _, err := s.blockMetasFromOldest()\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"get block metas from oldest\")\n\t}\n\n\tif len(metas) == 0 {\n\t\treturn true, nil\n\t}\n\n\tmeta, err := ReadMetaFile(s.metadataFilePath)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"read meta file\")\n\t}\n\n\tuploaded := make(map[ulid.ULID]struct{}, len(meta.Uploaded))\n\tfor _, id := range meta.Uploaded {\n\t\tuploaded[id] = struct{}{}\n\t}\n\n\tfor _, m := range metas {\n\t\tif _, ok := uploaded[m.ULID]; !ok {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\treturn true, nil\n}\n\n// Sync performs a single synchronization, which ensures all non-compacted local blocks have been uploaded\n// to the object bucket once.","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/shipper/shipper.go#L303-L339","documentation":"Wraps a failure from ReadMetaFile(s.metadataFilePath) — reading the shipper's own thanos.json/meta.json tracking file that records which block ULIDs were already uploaded. If this file cannot be read (and is not an expected fresh-install missing file), AreAllBlocksUploaded cannot determine upload state and fails.","triggerScenarios":"Calling AreAllBlocksUploaded when the shipper's metadata file exists but is corrupt, unreadable (permissions), or the read fails with an I/O error other than the tolerated not-exist case.","commonSituations":"Truncated metadata file after power loss; wrong ownership/permissions on the data dir; read-only filesystem; metadata file deleted while blocks remain.","solutions":["Inspect the wrapped error; if the file is corrupt, delete it — the shipper will re-detect uploaded blocks via bucket Exists checks and rewrite it.","Fix file permissions/ownership so the sidecar process can read the data directory.","Check that the underlying filesystem is healthy and writable.","Restart the sidecar after repair so it rebuilds the upload manifest."],"exampleFix":"// before\n// read meta file: parse /data/thanos-meta.json: unexpected end of JSON input\n// after\n// $ rm /data/thanos-meta.json   # shipper will re-scan the bucket and recreate it\n// $ systemctl restart thanos-sidecar","handlingStrategy":"fallback","validationCode":"if f, err := os.Open(metadataFilePath); err != nil {\n    if !os.IsNotExist(err) {\n        log.Printf(\"shipper metadata unreadable, will need repair: %v\", err)\n    }\n} else { f.Close() }","typeGuard":null,"tryCatchPattern":"ok, err := shipper.AreAllBlocksUploaded()\nif err != nil && strings.Contains(err.Error(), \"read meta file\") {\n    // safe remediation: delete the corrupt metadata file; shipper rebuilds it from bucket Exists checks\n    os.Remove(metadataFilePath)\n    ok, err = shipper.AreAllBlocksUploaded()\n}","preventionTips":["Ensure the metadata file lives on a crash-consistent filesystem","Don't edit or delete thanos metadata files while the sidecar runs","Keep data-dir ownership consistent across sidecar restarts/upgrades"],"tags":["filesystem","metadata","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"}