compact: Update filtered blocks list before second downsample pass #7492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7488
If the second downsampling pass is given the same filteredMetas list as the first pass, it will create duplicates of blocks created in the first pass.
It will also not be able to do further downsampling e.g 5m->1h using blocks created in the first pass, as it will not be aware of them.
The metadata was already being synced before the second pass, but not updated into the filteredMetas list.
Changes
Re-uses the same block filtering logic from the first pass, to regenerate the list of filtered blocks from freshly synced metadata before the second pass.
I haven't made any changes regarding the metrics logic that takes place after the first filtering:
thanos/cmd/thanos/compact.go
Lines 465 to 469 in 57b42d1
as I'm not sure what exactly this is doing. So there may be some downsamples that happen in the second pass that aren't counted in the metrics, if that's what it's doing. Let's keep that separate to this fix.
Verification
Tested against a bucket that was creating duplicate downsampled blocks on v0.35.1.
Verified in compactor logs that no duplicate block is created on the second pass: #7488 (comment)