Skip to content

Compactor: skip parquet converter files when downloading blocks - #7972

Merged
SungJin1212 merged 3 commits into
cortexproject:masterfrom
souvik-biswas-dev:fix-compactor-skip-parquet-download
Nov 30, 2026
Merged

SungJin1212 merged 3 commits into
cortexproject:masterfrom
souvik-biswas-dev:fix-compactor-skip-parquet-download

Conversation

@souvik-biswas-dev

Copy link
Copy Markdown
Contributor

What this PR does:

The parquet converter writes *.parquet files and parquet-converter-mark.json under the same object prefix as the TSDB block. block.Download lists everything under that prefix and downloads it, with no allowlist or filter, so the compactor pulled these files onto local disk even though compaction only reads index and chunks/.

block.Download is vendored Thanos code. It builds its own ignore list (meta.json plus files whose hash already matches) and overwrites any WithDownloadIgnoredPaths option passed by the caller, so neither option from the issue can be implemented from Cortex alone.

This PR instead wraps the per-tenant bucket used for compaction in compactUser, so parquet files and the converter marker are hidden from Iter and IterWithAttributes. Reads, uploads and deletes are unchanged. The blocks cleaner and the other components keep using the unwrapped bucket, so they still see these files and delete them together with the block. The compaction path only calls MarkForDeletion, which never lists the block.

Tests cover the filtered listings, reads staying unfiltered, the filter surviving WithExpectedErrs, and block.Download skipping the parquet files (with an unfiltered control download that does fetch them).

Which issue(s) this PR fixes:
Fixes #7967

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags

if strings.HasSuffix(name, objstore.DirDelim) {
return false
}
return strings.HasSuffix(name, parquetFileSuffix) || path.Base(name) == cortex_parquet.ConverterMarkerFileName

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The converter also writes parquet-no-convert-mark.json under the block prefix when it skips a block with too many label names.

How about filtering it as well? It's tiny, but for consistency.

@SungJin1212

SungJin1212 commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Would you mind adding a compactor-level test?
Maybe two compactable blocks plus parquet files in the bucket, run a compaction cycle, and assert that no *.parquet object was fetched.

@souvik-biswas-dev

Copy link
Copy Markdown
Contributor Author

Thanks for the review, both points are addressed in the latest commit. The filter now also hides parquet-no-convert-mark.json, covered by the bucket-level tests and mentioned in the CHANGELOG entry. I also added a compactor-level test, TestCompactor_ShouldNotDownloadParquetFilesWhenCompacting: it puts two real TSDB blocks plus parquet files and both markers in an in-memory bucket, runs a compaction cycle, records every object read, and asserts that the index and chunks were fetched while no parquet file or marker was. I checked that it fails without the filter (it reports a fetched nested/2.chunks.parquet).

Comment on lines +19 to +26
var parquetTestFiles = []string{
"0.labels.parquet",
"0.chunks.parquet",
"1.labels.parquet",
"nested/2.chunks.parquet",
cortex_parquet.ConverterMarkerFileName,
cortex_parquet.NoConvertMarkerFileName,
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one nit.
Could you declare the file list inline in each test instead?

@souvik-biswas-dev

Copy link
Copy Markdown
Contributor Author

Thanks! Done: each test now declares its parquet file list inline, and the shared variable is gone (the upload helper takes the list as an argument).

@souvik-biswas-dev

Copy link
Copy Markdown
Contributor Author

Friendly ping: the nit from the last review is addressed. Could a maintainer approve the workflow run for the latest commit and take another look when you have time? Thanks!

@SungJin1212

Copy link
Copy Markdown
Member

@friedrichg
Could you take a look?

@sandy2008 sandy2008 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against #7967: only the compaction listing hides the parquet files, and the blocks cleaner still sees them. The new tests fail on master and pass here. LGTM. CHANGELOG.md needs a rebase onto master.

The parquet converter writes its output under the same object prefix as
the TSDB block, along with parquet-converter-mark.json. block.Download
lists and downloads everything under that prefix and has no allowlist or
filter for these files, so the compactor pulled *.parquet files and the
marker onto local disk even though compaction only reads the index and
chunks.

block.Download is vendored Thanos code and builds its own ignore list,
so the filter cannot be passed in from here. Wrap the per-tenant bucket
used for compaction so that parquet files and the converter marker are
hidden from Iter and IterWithAttributes. Reads, uploads and deletes are
unchanged, and the blocks cleaner keeps using the unwrapped bucket, so
it still sees and deletes these files with the block.

Fixes cortexproject#7967

Signed-off-by: Souvik Biswas <[email protected]>
…test

The parquet converter also writes parquet-no-convert-mark.json under the block prefix when it skips a block with too many label names. Hide it from listings together with the other parquet converter files.

Add a compactor-level test: two real TSDB blocks plus parquet files and both markers in an in-memory bucket, run a compaction cycle, and assert that the index and chunks were read while no parquet file or marker was.

Signed-off-by: Souvik Biswas <[email protected]>
@souvik-biswas-dev

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master and resolved the CHANGELOG conflict; no code changes.

@souvik-biswas-dev
souvik-biswas-dev force-pushed the fix-compactor-skip-parquet-download branch from be0d23f to 9be3f71 Compare November 30, 2026 05:01
@SungJin1212

Copy link
Copy Markdown
Member

@souvik-biswas-dev
Thanks for the contribution.

@SungJin1212
SungJin1212 merged commit 7da992e into cortexproject:master Nov 30, 2026
40 checks passed
@souvik-biswas-dev
souvik-biswas-dev deleted the fix-compactor-skip-parquet-download branch December 1, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compactor downloads parquet converter files that compaction does not use

3 participants