thanos-io/thanos · error

open temporary block blockDir

Error message

open temporary block blockDir

What it means

Wraps fileutil.OpenDir in streamedBlockWriter.syncDir: the temporary block directory being finalized could not be opened for fsync (it vanished, permissions changed, or was never fully created). The downsampled block cannot be made durable.

Solutions

  1. Verify the block directory path exists before Close.
  2. Check permissions on the temporary block directory.
  3. Inspect the wrapped OS error (ENOENT, EACCES) for the root cause.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/compact/downsample/streamed_block_writer.go:192 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/5c13d130bcb42f61. Report an issue: GitHub.

Appendix: source

Thrown at pkg/compact/downsample/streamed_block_writer.go:192

	}

	// No error, claim success.

	level.Info(w.logger).Log(
		"msg", "finalized downsampled block",
		"mint", w.meta.MinTime,
		"maxt", w.meta.MaxTime,
		"ulid", w.meta.ULID,
		"resolution", w.meta.Thanos.Downsample.Resolution,
	)
	return nil
}

// syncDir syncs blockDir on disk.
func (w *streamedBlockWriter) syncDir() (err error) {
	df, err := fileutil.OpenDir(w.blockDir)
	if err != nil {
		return errors.Wrap(err, "open temporary block blockDir")
	}

	defer runutil.CloseWithErrCapture(&err, df, "close temporary block blockDir")

	if err := fileutil.Fdatasync(df); err != nil {
		return errors.Wrap(err, "sync temporary blockDir")
	}

	return nil
}

// writeMetaFile writes meta file.
func (w *streamedBlockWriter) writeMetaFile() error {
	w.meta.Version = metadata.TSDBVersion1
	w.meta.Thanos.Source = metadata.CompactorSource
	w.meta.Thanos.SegmentFiles = block.GetSegmentFiles(w.blockDir)
	w.meta.Stats.NumChunks = w.totalChunks
	w.meta.Stats.NumSamples = w.totalSamples

View on GitHub (pinned to 35b8b99117)