{"record":{"id":"458b9dfa6fd9fcea","repo":"thanos-io/thanos","slug":"opening-tsdb-directory","errorCode":null,"errorMessage":"opening tsdb directory","messagePattern":"opening tsdb directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":462,"sourceCode":"\t\tg.Add(func() error {\n\t\t\tdefer runutil.CloseWithLogOnErr(logger, bkt, \"bucket client\")\n\n\t\t\tpromReadyTimeout := conf.prometheus.readyTimeout\n\t\t\textLabelsCtx, cancel := context.WithTimeout(ctx, promReadyTimeout)\n\t\t\tdefer cancel()\n\n\t\t\tif err := runutil.Retry(2*time.Second, extLabelsCtx.Done(), func() error {\n\t\t\t\tif m.Labels().Len() == 0 {\n\t\t\t\t\treturn errors.New(\"not uploading as no external labels are configured yet - is Prometheus healthy/reachable?\")\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}); err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"aborting as no external labels found after waiting %s\", promReadyTimeout)\n\t\t\t}\n\n\t\t\tdataDir, err := os.OpenRoot(conf.tsdb.path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"opening tsdb directory\")\n\t\t\t}\n\t\t\tdefer runutil.CloseWithLogOnErr(logger, dataDir, \"tsdb directory\")\n\n\t\t\ts := shipper.New(\n\t\t\t\tbkt,\n\t\t\t\tdataDir,\n\t\t\t\tshipper.WithLogger(logger),\n\t\t\t\tshipper.WithRegisterer(reg),\n\t\t\t\tshipper.WithSource(metadata.SidecarSource),\n\t\t\t\tshipper.WithHashFunc(metadata.HashFunc(conf.shipper.hashFunc)),\n\t\t\t\tshipper.WithMetaFileName(conf.shipper.metaFileName),\n\t\t\t\tshipper.WithLabels(m.Labels),\n\t\t\t\tshipper.WithUploadCompacted(conf.shipper.uploadCompacted),\n\t\t\t\tshipper.WithAllowOutOfOrderUploads(conf.shipper.allowOutOfOrderUpload),\n\t\t\t\tshipper.WithSkipCorruptedBlocks(conf.shipper.skipCorruptedBlocks),\n\t\t\t\tshipper.WithUploadConcurrency(conf.shipper.uploadConcurrency),\n\t\t\t)\n","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L444-L480","documentation":"The sidecar failed to open the local TSDB data directory (os.OpenRoot on conf.tsdb.path) when constructing the block shipper. This is a filesystem-level failure and prevents block upload from starting at all.","triggerScenarios":"os.OpenRoot(conf.tsdb.path) returns an error: the path given via --tsdb.path does not exist, is not a directory, or the process lacks read permission on it.","commonSituations":"--tsdb.path typo or default 'data/' used while Prometheus stores data elsewhere; sidecar running in a container without the Prometheus data volume mounted; permission mismatch between Prometheus (different uid) and the sidecar process.","solutions":["Point --tsdb.path at the actual Prometheus data directory (the one containing wal/ and block dirs).","Ensure the directory exists and the sidecar's user has read access (check mounts in container deployments).","Verify with ls -la <tsdb.path> as the same user the sidecar runs as.","Confirm the Prometheus data volume is mounted before the sidecar starts."],"exampleFix":"# before\nsidecar --tsdb.path=data ...\n# after\nsidecar --tsdb.path=/var/lib/prometheus ...","handlingStrategy":"validation","validationCode":"stat, err := os.Stat(tsdbPath)\nif err != nil || !stat.IsDir() { return fmt.Errorf(\"tsdb path %s missing\", tsdbPath) }","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if os.IsNotExist(errors.Unwrap(err)) { /* fix --tsdb.path */ }\n}","preventionTips":["Mount the Prometheus data volume into sidecar containers before startup.","Verify --tsdb.path in deployment manifests with a pre-start check.","Run the sidecar as a user with read access to the data dir."],"tags":["filesystem","thanos-sidecar","configuration","directory"],"backgroundTag":"file-open-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"}