{"record":{"id":"87e40efb4408b846","repo":"thanos-io/thanos","slug":"found-that-tsdb-max-time-is-s-and-min-time-is-s","errorCode":null,"errorMessage":"found that TSDB Max time is %s and Min time is %s. Compaction needs to be disabled (storage.tsdb.min-block-duration = storage.tsdb.max-block-duration)","messagePattern":"found that TSDB Max time is (.+?) and Min time is (.+?)\\. Compaction needs to be disabled \\(storage\\.tsdb\\.min-block-duration = storage\\.tsdb\\.max-block-duration\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":531,"sourceCode":"\t\tlevel.Warn(logger).Log(\"msg\", \"failed to check Prometheus flags, due to potentially older Prometheus. No extra validation is done.\", \"err\", flagErr)\n\t\treturn nil\n\t}\n\n\tif flags.TSDBDelayCompact != \"\" {\n\t\tthanosMetaPath := filepath.Join(conf.tsdb.path, conf.shipper.metaFileName)\n\t\tif filepath.Clean(flags.TSDBDelayCompact) != filepath.Clean(thanosMetaPath) {\n\t\t\treturn errors.Errorf(\n\t\t\t\t\"found that Prometheus and Thanos use different paths for tracking block uploads. \"+\n\t\t\t\t\t\"Prometheus uses --storage.tsdb.delay-compact-file.path=%s while Thanos will write to %s, they must both use the same path.\",\n\t\t\t\tflags.TSDBDelayCompact, thanosMetaPath,\n\t\t\t)\n\t\t}\n\t}\n\n\t// Check if compaction is disabled.\n\tif flags.TSDBMinTime != flags.TSDBMaxTime && flags.TSDBDelayCompact == \"\" {\n\t\tif !conf.shipper.ignoreBlockSize {\n\t\t\treturn errors.Errorf(\"found that TSDB Max time is %s and Min time is %s. \"+\n\t\t\t\t\"Compaction needs to be disabled (storage.tsdb.min-block-duration = storage.tsdb.max-block-duration)\", flags.TSDBMaxTime, flags.TSDBMinTime)\n\t\t}\n\t\tlevel.Warn(logger).Log(\"msg\", \"flag to ignore Prometheus min/max block duration flags differing is being used. If the upload of a 2h block fails and a Prometheus compaction happens that block may be missing from your Thanos bucket storage.\")\n\t}\n\t// Check if block time is 2h.\n\tif flags.TSDBMinTime != model.Duration(2*time.Hour) {\n\t\tlevel.Warn(logger).Log(\"msg\", \"found that TSDB block time is not 2h. Only 2h block time is recommended.\", \"block-time\", flags.TSDBMinTime)\n\t}\n\n\treturn nil\n}\n\ntype promMetadata struct {\n\tpromURL *url.URL\n\n\tmtx          sync.Mutex\n\tmint         int64\n\tmaxt         int64","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L513-L549","documentation":"validatePrometheus enforces that Prometheus compaction is disabled when shipping blocks: if TSDBMinTime != TSDBMaxTime (variable block durations mean compaction is on) and --storage.tsdb.delay-compact-file is not used, the sidecar refuses to start unless --shipper.ignore-block-size is set. Shipping blocks while Prometheus compacts them can lose data from the bucket.","triggerScenarios":"flags.TSDBMinTime != flags.TSDBMaxTime && flags.TSDBDelayCompact == \"\" && !conf.shipper.ignoreBlockSize — i.e. Prometheus's min/max block duration flags differ (default 2h/10d) with no delay-compact-file workaround.","commonSituations":"Default Prometheus deployment with compaction enabled and Thanos sidecar in upload mode; operator unaware compaction must be off or routed through Thanos Compactor; ignoring the warning via ignore-block-size and later finding gaps after a failed 2h block upload.","solutions":["Set --storage.tsdb.min-block-duration=2h --storage.tsdb.max-block-duration=2h on Prometheus to disable compaction.","Or use --storage.tsdb.delay-compact-file pointing at the shipper meta.json path (see error 166).","Or pass --shipper.ignore-block-size to the sidecar if you accept the risk of missing blocks after failed uploads + compaction.","Let Thanos Compactor handle all downsampling/compaction on the bucket."],"exampleFix":"# before\nprometheus --config.file=prometheus.yml\n# after\nprometheus --config.file=prometheus.yml \\\n  --storage.tsdb.min-block-duration=2h \\\n  --storage.tsdb.max-block-duration=2h","handlingStrategy":"validation","validationCode":"if promMinBlock != promMaxBlock && !delayCompactSet && !ignoreBlockSize {\n    return errors.New(\"disable Prometheus compaction before enabling sidecar upload\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on min-block-duration=max-block-duration=2h in all Prometheus configs used with Thanos.","Prefer the --storage.tsdb.delay-compact-file mechanism over --shipper.ignore-block-size.","Never enable sidecar upload against a compacting Prometheus."],"tags":["configuration","validation","compaction","data-loss-risk"],"backgroundTag":"conflicting-config-options","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"}