{"record":{"id":"9de6a16860803788","repo":"thanos-io/thanos","slug":"open-compact-root-directory","errorCode":null,"errorMessage":"open compact root directory","messagePattern":"open compact root directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compact/compact.go","lineNumber":1490,"sourceCode":"\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}()\n\n\t// Loop over bucket and compact until there's no work left.\n\tfor {\n\t\tvar (","sourceCodeStart":1472,"sourceCodeEnd":1508,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compact/compact.go#L1472-L1508","documentation":"Wraps the os.MkdirAll at the top of BucketCompactor.Compact ensuring the compaction working directory exists for this run. Same failure modes as construction-time creation: unwritable path, read-only filesystem, or occupied path.","triggerScenarios":"Thrown at pkg/compact/compact.go:1490 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify kernel/filesystem supports openat2-style rooted handles","Check permissions on the compact dir","Confirm the dir was not removed concurrently"],"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"}