thanos-io/thanos · error

sync temporary blockDir

Error message

sync temporary blockDir

What it means

Wraps fileutil.Fdatasync on the temporary block directory in streamedBlockWriter.syncDir: the fsync syscall failed (I/O error, unsupported filesystem), so directory entries for the downsampled block may not survive a crash.

Solutions

  1. Check kernel/filesystem support for directory fdatasync.
  2. Look for I/O errors in system logs.
  3. Retry Close; treat the block as not finalized on repeated failure.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/compact/downsample/streamed_block_writer.go:198 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/485634b5f66ecb02. Report an issue: GitHub.

Appendix: source

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

		"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
	w.meta.Stats.NumSeries = uint64(w.seriesRefs)

	return w.meta.WriteToDir(w.logger, w.blockDir)
}

View on GitHub (pinned to 35b8b99117)