thanos-io/thanos · error

create compact root directory

Error message

create compact root directory

What it means

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.

Solutions

  1. Check permissions on --data-dir
  2. Ensure sufficient disk space
  3. Verify the path is not a regular file
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/compact/compact.go:1486 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/9634169be8c1532b. Report an issue: GitHub.

Appendix: source

Thrown at pkg/compact/compact.go:1486

		logger:                         logger,
		sy:                             sy,
		grouper:                        grouper,
		planner:                        planner,
		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)
		}
	}()

View on GitHub (pinned to 35b8b99117)