-
Notifications
You must be signed in to change notification settings - Fork 179
Add WALSegmentSize as an option of tsdb creation #450
Conversation
That is strange the so in your case changing the For example if before the change you had 10x128mb = 1280mb after changing the default size to 12mb should end up with something like: 107x12mb = 1280mb |
before my patch, there was only one file in the wal folder After the patch (and the config) : the new folders (NOT the wal) with chunks are written as expected each 2 hours , with just one file The patch+config only affect the segments size of the WAL, and how many are at the same time. |
How i test :i go to my patched branch
|
yeah that is true, the checkpointing will be triggered more often which would clear the obsolete samples more often. @gouthamve , @fabxc can you think of any negative side effects of making this configurable? @glutamatt btw I don't see any reason why you should expose the defaultSegmentSize constant. |
https://github.com/prometheus/tsdb/pull/450/files#diff-7a117cbfd5485ed35efcbb2995c37aa0R48
Sure, but i prefer to lose some data on a reboot rather than burning my sd card (a changing/buying an other one will lead to more "unpersisted" data 🤡) |
I preferred to be fully backward compatible : In maybe if someone is interested of the project of my use case |
Making the wal segment configurable will be very useful for tests. |
Hi @krasi-georgiev , |
@glutamatt sorry for the delay. We started maintaining a change file so do you mind adding an entry for the API change and the new exposed https://github.com/prometheus/tsdb/blob/master/CHANGELOG.md |
43833e4
to
e1d9cb1
Compare
Done ! 👌 If you think about a better wording or syntax, I would be fine to update the changelog |
suggestions are commited and rebased with sign off ✅ |
sorry to be a pain but I just remembered that we need to add a test for this new behaviour. Something like: If you get stuck with the test ping me and I will try to help. |
👍
here we are : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot, just few minor nits.
f32a47a
to
eb6c9d2
Compare
minor nits done, you're welcome |
yep, all good, thanks for the patience. I just a did the 0.3.0 release and will wait for this to get merged in Prometheus and after that will merge your PR as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small change
Signed-off-by: Glutamatt <glutamatt@live.fr> Add unit test `TestWALSegmentSizeOption` Signed-off-by: Glutamatt <glutamatt@live.fr> code review feedback Signed-off-by: Glutamatt <glutamatt@live.fr>
@glutamatt thanks, |
do i wait for you to tag a new minor of tsdb, before creating a PR in prometheus repo ? if none of those, could you tell me how to proceed please @krasi-georgiev , thanks ! |
I think using a hash would be best. no need to block until the next release. |
Let's have a first use of the brand new go dependency manager. Thanks for the fast answer |
thanks for your patience and great work! |
@glutamatt btw Simon did a very good step by step section how to update a module: |
here it is |
Add WALSegmentSize as an option, and the corresponding flag "storage.tsdb.wal-segment-size" to tune the max size of wal segment files. The addressed base problem is to reduce the disk space used by wal segment files : on a raspberry pi, for instance, we often want to reduce write load of the sd card, then, the wal directory is mounted on a memory (space limited) partition. the default value of the segment max file size, pushed the size of directory to 128 MB for each segment , which is too much ram consumption on a rasp. the initial discussion is at prometheus-junkyard/tsdb#450
Problem to solve :
Prometheus server is running on a raspberry pi :
In order to preserve the SD Card lifetime, I mounted the WAL directory on the tmpfs (memory) partition.
The tmpfs partition is quickly full.
Solution :
Provides the wal semgent file size as an option via
wal.Options
structResults
Then, I will be able to limit the wal segment file sizes ( I set 1048576 for example ). Smaller files are written, and the oldest ones are truncated : the wal directory keep an acceptable size on tmpfs partition.
I prepared an associated patch on prometheus server project
It works perfectly on my raspberry now ✨
output of the prometheus server on the raspberry when it crashed