compaction: remove all cache dirs at the end of each run#1587
compaction: remove all cache dirs at the end of each run#1587bwplotka merged 14 commits intothanos-io:masterfrom
Conversation
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
| indexCacheDir = path.Join(dataDir, "index_cache") | ||
| ) | ||
|
|
||
| if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
Can we not remove it? I think we need that still. What if compactor crashes/is restarted not gracefully? Then deferred removal will fail and Thanos will use more disk then needed if not worse - might end up having corrupted blocks.
There was a problem hiding this comment.
this is not removed , it is just moved inside the .Compact() method. This makes it consitent with all the how the other components handle removing the tmp files.
There was a problem hiding this comment.
actually I just double checked and I removed it because it is redundant as the compactor removes these before every compaction in
Lines 1044 to 1047 in 3646e13
There was a problem hiding this comment.
Yes, but c.compactDir is different then downsamplingDir 🤔
There was a problem hiding this comment.
correction It is a duplicate of
thanos/cmd/thanos/downsample.go
Lines 134 to 136 in 95757ea
There was a problem hiding this comment.
Yes but that would be cleaned only after (!) compaction, so long time. I am 99% sure we need to keep this.
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
krasi-georgiev
left a comment
There was a problem hiding this comment.
I have now added tests which verify the correct behavior.
| indexCacheDir = path.Join(dataDir, "index_cache") | ||
| ) | ||
|
|
||
| if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
this is not removed , it is just moved inside the .Compact() method. This makes it consitent with all the how the other components handle removing the tmp files.
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
|
ping @bwplotka |
| "github.com/thanos-io/thanos/pkg/testutil" | ||
| ) | ||
|
|
||
| func TestCleanupCompactCacheFolder(t *testing.T) { |
There was a problem hiding this comment.
Why not having those inside package responsible for deleting?
There was a problem hiding this comment.
because it will require duplicating the bootstrap function.
I thought to put the bootstrap in some reusable package, but don't think it is generic enough to be useful anywhere else.
If it happens that that func becomes useful in other tests would revisit and refactor.
| indexCacheDir = path.Join(dataDir, "index_cache") | ||
| ) | ||
|
|
||
| if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
Yes, but c.compactDir is different then downsamplingDir 🤔
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
a08d04b to
3c678b2
Compare
# Conflicts: # CHANGELOG.md Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
* remove all cache dirs at the end of each run Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * changelog Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * . Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * changelog formating and pr num. Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * added test for the compaction cleanup Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * added tests Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * check error Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * move GatherAndCompare to tesutil Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * comment Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * nit Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * Added back deletion of the downsampling dir. Signed-off-by: Bartek Plotka <bwplotka@gmail.com> * Fix after pull master. Signed-off-by: Bartek Plotka <bwplotka@gmail.com> Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Krasi Georgiev 8903888+krasi-georgiev@users.noreply.github.com
fixes: #1499
TODO