{"record":{"id":"518e2c6386c11cdd","repo":"thanos-io/thanos","slug":"found-d-chunks-non-completely-outside-the-block-t","errorCode":null,"errorMessage":"found %d chunks non-completely outside the block time range, found %d chunks completely outside the block time range","messagePattern":"found (.+?) chunks non-completely outside the block time range, found (.+?) chunks completely outside the block time range","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/block/index.go","lineNumber":148,"sourceCode":"\t}\n\treturn nil\n}\n\n// CriticalErr returns error if stats indicates critical block issue, that might solved only by manual repair procedure.\nfunc (i HealthStats) CriticalErr() error {\n\tvar errMsg []string\n\n\tn := i.OutsideChunks - (i.CompleteOutsideChunks + i.Issue347OutsideChunks)\n\tif n > 0 {\n\t\terrMsg = append(errMsg, fmt.Sprintf(\"found %d chunks non-completely outside the block time range\", n))\n\t}\n\n\tif i.CompleteOutsideChunks > 0 {\n\t\terrMsg = append(errMsg, fmt.Sprintf(\"found %d chunks completely outside the block time range\", i.CompleteOutsideChunks))\n\t}\n\n\tif len(errMsg) > 0 {\n\t\treturn errors.New(strings.Join(errMsg, \", \"))\n\t}\n\n\treturn nil\n}\n\n// AnyErr returns error if stats indicates any block issue.\nfunc (i HealthStats) AnyErr() error {\n\tvar errMsg []string\n\n\tif err := i.CriticalErr(); err != nil {\n\t\terrMsg = append(errMsg, err.Error())\n\t}\n\n\tif err := i.Issue347OutsideChunksErr(); err != nil {\n\t\terrMsg = append(errMsg, err.Error())\n\t}\n\n\tif err := i.OutOfOrderLabelsErr(); err != nil {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/index.go#L130-L166","documentation":"HealthStats.CriticalErr reports chunks found outside the block's declared [minTime, maxTime] range that are not auto-fixable: chunks partially overlapping the range (non-completely outside) and chunks entirely outside the range (complete outsiders, never accessed). Thanos treats these as critical block issues that can only be resolved by a manual repair procedure, since block metadata no longer matches actual chunk data.","triggerScenarios":"GatherIndexHealthStats flags every chunk with c.MinTime < minTime || c.MaxTime > maxTime; those fully outside (c.MinTime > maxTime || c.MaxTime < minTime) increment CompleteOutsideChunks, the rest minus issue-347 chunks count as non-completely outside; CriticalErr returns this message when either count > 0, joined by AnyErr during VerifyIndex.","commonSituations":"Block metadata (meta.json minTime/maxTime) edited or truncated manually; blocks corrupted by interrupted compaction/upload; issues from old Thanos/Prometheus versions that miscalculated block boundaries; partial block downloads in store gateways.","solutions":["Run block.Repair with IgnoreCompleteOutsideChunk (plus IgnoreIssue347OutsideChunk/IgnoreDuplicateOutsideChunk) to rewrite the block dropping outsiders.","If only metadata boundaries are wrong, recompute and rewrite meta.json minTime/maxTime from actual chunk data, then re-verify.","Delete the corrupted block and re-upload/re-backfill it from source data.","Manually inspect with `thanos tools bucket inspect` to scope damage before repair; never edit meta.json by hand going forward."],"exampleFix":"// before\nreturn stats.AnyErr() // found 2 chunks non-completely outside..., found 1 chunks completely outside...\n// after\n_, err := block.Repair(ctx, logger, dir, id, metadata.CompactorGrouperSource,\n    block.IgnoreCompleteOutsideChunk, block.IgnoreIssue347OutsideChunk, block.IgnoreDuplicateOutsideChunk)\nif err != nil { return err }\nreturn block.VerifyIndex(ctx, logger, filepath.Join(dir, id.String(), \"index\"), minTime, maxTime)","handlingStrategy":"validation","validationCode":"stats, err := block.GatherIndexHealthStats(ctx, logger, indexFn, minTime, maxTime)\nif err != nil { return err }\nif stats.OutsideChunks > stats.Issue347OutsideChunks {\n    return fmt.Errorf(\"block %s has %d non-recoverable outside chunks; manual repair needed\", id, stats.OutsideChunks-stats.Issue347OutsideChunks)\n}","typeGuard":null,"tryCatchPattern":"if err := stats.CriticalErr(); err != nil {\n    _, err := block.Repair(ctx, logger, dir, id, metadata.CompactorGrouperSource, block.IgnoreCompleteOutsideChunk)\n    return err\n}","preventionTips":["Never manually edit meta.json minTime/maxTime","Verify blocks after upload and before compaction","Monitor compaction/upload interruptions and re-upload partial blocks"],"tags":["tsdb","block-index","thanos","data-corruption","repair"],"backgroundTag":"internal-invariant-violation","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"}