prometheus/tsdb/chunks
Ayoub Mrini ead71bac5d
chore(tsdb): simplify cutSegmentFile by removing temp file indirection (#19020)
This will allow the simplification of the directIOWriter.

PR #7573 introduced a .tmp file + rename pattern in cutSegmentFile to
prevent mmap from seeing empty files after a crash. However, without an
fsync on the file itself, a crash could still leave the renamed file
with zero content or sth else. PR #8061 added repairLastChunkFile as the real fix,
extended in PR #11338 to detect zero magic numbers.

The .tmp indirection is redundant, both callers have crash safety:

- Head chunks: repairLastChunkFile removes corrupt last files on
  startup. No intermediary broken file can exist (handleChunkWriteError
  panics, so the corrupt file is always the last one).
- Compaction: files live in a .tmp-for-creation block directory, cleaned
  up entirely on failure or restart.

Remove the pattern for fewer syscalls and a simpler write path.

Signed-off-by: Ayoub Mrini <ayoubmrini424@gmail.com>
2026-07-08 11:38:55 +02:00
..
chunk_write_queue.go chore(lint): enable wg.Go 2026-02-17 15:21:51 +01:00
chunk_write_queue_test.go test: Enable parallel execution for chunk write queue tests (#17338) 2026-02-24 12:37:20 +01:00
chunks.go chore(tsdb): simplify cutSegmentFile by removing temp file indirection (#19020) 2026-07-08 11:38:55 +02:00
chunks_test.go Merge branch 'main' into st-main-sync2 2026-02-25 13:54:25 +00:00
head_chunks.go tsdb: close chunks_head dir handle when openMMapFiles fails 2026-04-17 14:26:15 +02:00
head_chunks_other.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
head_chunks_test.go chore(tsdb): simplify cutSegmentFile by removing temp file indirection (#19020) 2026-07-08 11:38:55 +02:00
head_chunks_windows.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
queue.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
queue_test.go test: Enable parallel execution for chunk write queue tests (#17338) 2026-02-24 12:37:20 +01:00
samples.go feat(tsdb): new AppenderV2 and AtST interface for chunks 2026-01-14 13:15:09 +01:00