prometheus / prometheus/prometheus
Idea: add a mode where Prometheus will do head compaction/WAL truncation before starting scraping
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 66.1k
- Forks
- 10.8k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 131
Description
Proposal
As @mattburgess said at https://github.com/prometheus/prometheus/issues/6934#issuecomment-945739611
would it be possible to run a compaction/WAL cleanup as soon as the replay has been completed? That would help us avoid the crash-loop we find ourselves in, whereby a pod restart causes WAL replay to happen, but then they never get cleaned up, so when the OOM-killer comes along the same WALs get replayed on the next restart and on and on we go in circles until we resign ourselves to removing the WALs and thereby losing data.
I found myself wanting this today.
I will add, I think it is important that we not start scraping until after this head compaction has finished, to keep memory usage down and avoid making the WAL any bigger, because if Prometheus OOMs again it will restart with a worse problem.
It could be a CLI flag to Prometheus, like --force-head-compaction-at-start.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Prometheus startup after WAL replay completes, and trace when scraping begins. Determine how the proposed --force-head-compaction-at-start mode should trigger head compaction and WAL cleanup before scraping, while preserving the stated behavior after a restart. Done means the cleanup finishes before scraping and the crash-loop scenario is addressed without requiring manual WAL deletion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100