{"record":{"id":"9634169be8c1532b","repo":"thanos-io/thanos","slug":"create-compact-root-directory","errorCode":null,"errorMessage":"create compact root directory","messagePattern":"create compact root directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compact/compact.go","lineNumber":1486,"sourceCode":"\t\tlogger:                         logger,\n\t\tsy:                             sy,\n\t\tgrouper:                        grouper,\n\t\tplanner:                        planner,\n\t\tcomp:                           comp,\n\t\tblockDeletableChecker:          blockDeletableChecker,\n\t\tcompactionLifecycleCallback:    compactionLifecycleCallback,\n\t\tcompactDir:                     compactDir,\n\t\tbkt:                            bkt,\n\t\tconcurrency:                    concurrency,\n\t\tskipBlocksWithOutOfOrderChunks: skipBlocksWithOutOfOrderChunks,\n\t\tblocksCleaner:                  blocksCleaner,\n\t}, nil\n}\n\n// Compact runs compaction over bucket.\nfunc (c *BucketCompactor) Compact(ctx context.Context) (rerr error) {\n\tif err := os.MkdirAll(c.compactDir, 0750); err != nil {\n\t\treturn errors.Wrap(err, \"create compact root directory\")\n\t}\n\tdir, err := os.OpenRoot(c.compactDir)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"open compact root directory\")\n\t}\n\n\tdefer func() {\n\t\trunutil.CloseWithLogOnErr(c.logger, dir, \"compact root directory\")\n\t\t// Do not remove the compactDir if an error has occurred\n\t\t// because potentially on the next run we would not have to download\n\t\t// everything again.\n\t\tif rerr != nil {\n\t\t\treturn\n\t\t}\n\t\tif err := os.RemoveAll(c.compactDir); err != nil {\n\t\t\tlevel.Error(c.logger).Log(\"msg\", \"failed to remove compaction work directory\", \"path\", c.compactDir, \"err\", err)\n\t\t}\n\t}()","sourceCodeStart":1468,"sourceCodeEnd":1504,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compact/compact.go#L1468-L1504","documentation":"Wraps the os.MkdirAll that creates the compactor's working root directory (compactDir, from --compact.dir or a temp dir). It fires when the directory cannot be created — permissions, disk full, or a file in the way — before any compaction work starts.","triggerScenarios":"Thrown at pkg/compact/compact.go:1486 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions on --data-dir","Ensure sufficient disk space","Verify the path is not a regular file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}