thanos-io/thanos · error

open compact root directory

Error message

open compact root directory

What it means

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.

Solutions

  1. Verify kernel/filesystem supports openat2-style rooted handles
  2. Check permissions on the compact dir
  3. Confirm the dir was not removed concurrently
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/compact/compact.go:1490 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/9de6a16860803788. Report an issue: GitHub.

Appendix: source

Thrown at pkg/compact/compact.go:1490

		comp:                           comp,
		blockDeletableChecker:          blockDeletableChecker,
		compactionLifecycleCallback:    compactionLifecycleCallback,
		compactDir:                     compactDir,
		bkt:                            bkt,
		concurrency:                    concurrency,
		skipBlocksWithOutOfOrderChunks: skipBlocksWithOutOfOrderChunks,
		blocksCleaner:                  blocksCleaner,
	}, nil
}

// Compact runs compaction over bucket.
func (c *BucketCompactor) Compact(ctx context.Context) (rerr error) {
	if err := os.MkdirAll(c.compactDir, 0750); err != nil {
		return errors.Wrap(err, "create compact root directory")
	}
	dir, err := os.OpenRoot(c.compactDir)
	if err != nil {
		return errors.Wrap(err, "open compact root directory")
	}

	defer func() {
		runutil.CloseWithLogOnErr(c.logger, dir, "compact root directory")
		// Do not remove the compactDir if an error has occurred
		// because potentially on the next run we would not have to download
		// everything again.
		if rerr != nil {
			return
		}
		if err := os.RemoveAll(c.compactDir); err != nil {
			level.Error(c.logger).Log("msg", "failed to remove compaction work directory", "path", c.compactDir, "err", err)
		}
	}()

	// Loop over bucket and compact until there's no work left.
	for {
		var (

View on GitHub (pinned to 35b8b99117)