{"record":{"id":"5de9437be999404c","repo":"thanos-io/thanos","slug":"create-working-downsample-directory","errorCode":null,"errorMessage":"create working downsample directory","messagePattern":"create working downsample directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/compact.go","lineNumber":360,"sourceCode":"\n\t// Instantiate the compactor with different time slices. Timestamps in TSDB\n\t// are in milliseconds.\n\tcomp, err := tsdb.NewLeveledCompactor(ctx, reg, logutil.GoKitLogToSlog(logger), levels, downsample.NewPool(), mergeFunc)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"create compactor\")\n\t}\n\n\tvar (\n\t\tcompactDir      = path.Join(conf.dataDir, \"compact\")\n\t\tdownsamplingDir = path.Join(conf.dataDir, \"downsample\")\n\t)\n\n\tif err := os.MkdirAll(compactDir, os.ModePerm); err != nil {\n\t\treturn errors.Wrap(err, \"create working compact directory\")\n\t}\n\n\tif err := os.MkdirAll(downsamplingDir, os.ModePerm); err != nil {\n\t\treturn errors.Wrap(err, \"create working downsample directory\")\n\t}\n\n\tgrouper := compact.NewDefaultGrouper(\n\t\tlogger,\n\t\tinsBkt,\n\t\tconf.acceptMalformedIndex,\n\t\tenableVerticalCompaction,\n\t\treg,\n\t\tcompactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, \"\"),\n\t\tcompactMetrics.garbageCollectedBlocks,\n\t\tcompactMetrics.blocksMarked.WithLabelValues(metadata.NoCompactMarkFilename, metadata.OutOfOrderChunksNoCompactReason),\n\t\tmetadata.HashFunc(conf.hashFunc),\n\t\tconf.blockFilesConcurrency,\n\t\tconf.compactBlocksFetchConcurrency,\n\t)\n\tvar planner compact.Planner\n\n\ttsdbPlanner := compact.NewPlanner(logger, levels, noCompactMarkerFilter)","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/compact.go#L342-L378","documentation":"os.MkdirAll failed to create (or verify) the downsample working directory under --data-dir. Fires when the filesystem is unwritable, full, or the path conflicts with a non-directory. This aborts runCompact startup before any compaction runs.","triggerScenarios":"os.MkdirAll(downsamplingDir, os.ModePerm) fails due to permissions, a file at that path, read-only filesystem, or ENOSPC.","commonSituations":"Same as the compact dir error: PV permission issues, non-root process, full disk, or path collision with an existing file.","solutions":["Ensure <dataDir> is writable by the process user (chown/chmod).","Remove any regular file occupying <dataDir>/downsample.","Check volume free space and read-write mount status."],"exampleFix":"// before\n/data/downsample exists as a file (from a bad restore)\n// after\nrm /data/downsample && mkdir -p /data/downsample && chown -R thanos:thanos /data","handlingStrategy":"validation","validationCode":"if err := os.MkdirAll(path.Join(dataDir, \"downsample\"), 0o755); err != nil {\n    return fmt.Errorf(\"cannot prepare downsample dir under %q: %w\", dataDir, err)\n}","typeGuard":null,"tryCatchPattern":"if err := runCompact(...); err != nil {\n    if strings.Contains(err.Error(), \"create working downsample directory\") {\n        logger.Error(err, \"downsample dir unusable; check permissions and free space\")\n    }\n    return err\n}","preventionTips":["Provision the whole dataDir tree (including downsample/) with correct ownership at startup","Alert on disk-full conditions for the compact data volume","Use the same writable volume for compact and downsample directories"],"tags":["filesystem","permissions","startup"],"backgroundTag":"mkdir-permission-denied","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"}