{"record":{"id":"445b83c63cc757fb","repo":"thanos-io/thanos","slug":"new-bucket-block","errorCode":null,"errorMessage":"new bucket block","messagePattern":"new bucket block","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":896,"sourceCode":"\t\t\trunutil.CloseWithErrCapture(&err, indexHeaderReader, \"index-header\")\n\t\t}\n\t}()\n\n\tb, err := newBucketBlock(\n\t\tctx,\n\t\ts.metrics,\n\t\tmeta,\n\t\ts.bkt,\n\t\tdir,\n\t\ts.indexCache,\n\t\ts.chunkPool,\n\t\tindexHeaderReader,\n\t\ts.partitioner,\n\t\ts.blockEstimatedMaxSeriesFunc,\n\t\ts.blockEstimatedMaxChunkFunc,\n\t)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new bucket block\")\n\t}\n\tdefer func() {\n\t\tif err != nil {\n\t\t\trunutil.CloseWithErrCapture(&err, b, \"index-header\")\n\t\t}\n\t}()\n\n\ts.mtx.Lock()\n\tdefer s.mtx.Unlock()\n\n\tset, ok := s.blockSets[h]\n\tif !ok {\n\t\tset = newBucketBlockSet(lset)\n\t\ts.blockSets[h] = set\n\t}\n\n\tif err = set.add(b); err != nil {\n\t\treturn errors.Wrap(err, \"add block to set\")","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L878-L914","documentation":"Thrown in pkg/store/bucket.go when BucketStore.loadBlock fails to construct a new bucket block (Block.NewBucketBlock) from the object-store bucket. It wraps any failure while opening the block's index, chunks, tombstones, or index-header during block sync/open. The deferred handler closes the partially-opened block so resources are not leaked.","triggerScenarios":"Block discovery finds a meta.json ULID in the bucket, and NewBucketBlock returns an error: the block directory cannot be downloaded/opened, index-header cannot be built (corrupt or missing index-header file when lazy index-header is enabled), or the underlying object storage call fails.","commonSituations":"Corrupted or truncated block uploads (e.g. compactor died mid-upload), missing index-header with index-header lazy downloading enabled, object-store permission or throttling errors during sync, blocks removed from the bucket while the store is syncing them.","solutions":["Verify the block in the bucket is complete: check for meta.json, index, and chunks files; re-upload or remove the corrupted block.","Rebuild or delete the stale index-header file (thanos tools bucket verify / remove the .index-header and let the store rebuild it).","Check object-store credentials, permissions, and rate limits in the store gateway logs for the wrapped root error.","Restart the store gateway to re-run the block sync after fixing the bucket contents."],"exampleFix":"// before: block partially uploaded, index missing\n// after: ensure block is uploaded atomically\nfunc uploadBlock(bkt objstore.Bucket, dir string) error {\n\treturn objstore.UploadDir(context.Background(), bkt, dir, dir) // uploads meta.json last\n}","handlingStrategy":"try-catch","validationCode":"// Before opening: confirm block completeness\nfor _, f := range []string{\"meta.json\", \"index\"} {\n\tif ok, _ := bkt.Exists(ctx, path.Join(ulid.String(), f)); !ok {\n\t\treturn fmt.Errorf(\"block %s incomplete: missing %s\", ulid, f)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := store.SyncBlocks(ctx); err != nil {\n\tvar blockErr error\n\tif errors.As(err, &blockErr) && strings.Contains(err.Error(), \"new bucket block\") {\n\t\t// mark block ID as suspect and skip it this sync cycle\n\t\tlogger.Warn(\"skipping unloadable block\", \"err\", err)\n\t} else {\n\t\treturn err\n\t}\n}","preventionTips":["Always upload blocks atomically (meta.json last) from compactor/ruler.","Enable index-header lazy download and monitor index-header build errors.","Run periodic 'thanos tools bucket verify' against the bucket.","Alert on store gateway sync failures and object-store 4xx/5xx rates."],"tags":["object-storage","block-sync","thanos-store"],"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"}