Skip to content

Allow periodic compaction for non-block-based table formats (#15782) - #15782

Open
joshkang97 wants to merge 1 commit into
meta:mainfrom
joshkang97:export-D134432323
Open

joshkang97 wants to merge 1 commit into
meta:mainfrom
joshkang97:export-D134432323

Conversation

@joshkang97

@joshkang97 joshkang97 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Summary

periodic_compaction_seconds was limited to block-based tables when it was added in RocksDB 6.2 (#5166), because file age came from the file_creation_time table property, which only the block-based table builder writes. Since RocksDB 6.6, flush and compaction record file_creation_time and oldest_ancester_time in the MANIFEST for every output file, and VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction() prefers those, so file selection no longer depends on the table format. ColumnFamilyData::ValidateOptions() still rejected an explicit value for any other table factory, so DB::Open() failed with NotSupported.

This change removes that check, so an explicit periodic_compaction_seconds works with any table format. The 30-day default still applies only to block-based tables, so other formats see no new compactions unless they set the option. In those formats, a file with no MANIFEST time, such as one written before 6.6, falls back to its modification time, so it may be compacted late but never early. ttl keeps its block-based-only check. Bonus: db_stress no longer rejects --periodic_compaction_seconds with a non-block-based --table_factory_uri.

Differential Revision: D134432323

@meta-cla meta-cla Bot added the CLA Signed label Nov 25, 2026
@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown

@joshkang97 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134432323.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 121.6s.

joshkang97 added a commit to joshkang97/rocksdb that referenced this pull request Nov 25, 2026
Summary:
Pull Request resolved: meta#15782

## Summary
`periodic_compaction_seconds` makes RocksDB compact files once they reach a given age, mainly so that compaction filters eventually see data in files that would otherwise never be compacted again. `ColumnFamilyData::ValidateOptions()` rejects any explicit non-zero value unless the table factory is the block-based table, so `DB::Open()` fails with `NotSupported` for every other table format, including custom table factories. Separately, `SanitizeOptions()` applies the 30-day default (universal compaction, or leveled compaction with a compaction filter) only to block-based tables. Other formats therefore have no way to get periodic compaction at all.

The restriction dates from when periodic compaction was added in RocksDB 6.2 (meta#5166). It aged files by a new `file_creation_time` table property, which only the block-based table builder writes; other formats had only the file's modification time, which resets when a file is copied. RocksDB 6.6 started recording file times in the MANIFEST, but the table format check was not revisited.

The restriction is no longer needed. `VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()` ages a file by its `file_creation_time`, then `oldest_ancestor_time`, which flush and compaction record in the MANIFEST for every output file whatever the table format. It falls back to the table property and then to the file's modification time. The periodic compaction pickers do not depend on the table format either.

This change drops the block-based-only validation of `periodic_compaction_seconds`, so an explicit value now works with any table format. The default is unchanged and still applies only to block-based tables, so users of other formats see no new compactions unless they opt in. In those formats, a file with no MANIFEST time, such as one written before 6.6, is aged by its modification time, so it may be compacted late but never early. `ttl` keeps its block-based-only validation. Bonus: db_stress no longer rejects `--periodic_compaction_seconds` with a non-block-based `--table_factory_uri`.

Differential Revision: D134432323
@meta-codesync meta-codesync Bot changed the title Allow periodic compaction for non-block-based table formats Allow periodic compaction for non-block-based table formats (#15782) Nov 25, 2026
joshkang97 added a commit to joshkang97/rocksdb that referenced this pull request Nov 25, 2026
Summary:
Pull Request resolved: meta#15782

## Summary

`periodic_compaction_seconds` was limited to block-based tables when it was added in RocksDB 6.2 (meta#5166), because file age came from the `file_creation_time` table property, which only the block-based table builder writes. Since RocksDB 6.6, flush and compaction record `file_creation_time` and `oldest_ancester_time` in the MANIFEST for every output file, and `VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()` prefers those, so file selection no longer depends on the table format. `ColumnFamilyData::ValidateOptions()` still rejected an explicit value for any other table factory, so `DB::Open()` failed with `NotSupported`.

This change removes that check, so an explicit `periodic_compaction_seconds` works with any table format. The 30-day default still applies only to block-based tables, so other formats see no new compactions unless they set the option. In those formats, a file with no MANIFEST time, such as one written before 6.6, falls back to its modification time, so it may be compacted late but never early. `ttl` keeps its block-based-only check. Bonus: db_stress no longer rejects `--periodic_compaction_seconds` with a non-block-based `--table_factory_uri`.

Differential Revision: D134432323
@joshkang97
joshkang97 force-pushed the export-D134432323 branch 2 times, most recently from 5d95863 to a313ad0 Compare November 27, 2026 12:10
joshkang97 added a commit to joshkang97/rocksdb that referenced this pull request Nov 27, 2026
Summary:
Pull Request resolved: meta#15782

## Summary

`periodic_compaction_seconds` was limited to block-based tables when it was added in RocksDB 6.2 (meta#5166), because file age came from the `file_creation_time` table property, which only the block-based table builder writes. Since RocksDB 6.6, flush and compaction record `file_creation_time` and `oldest_ancester_time` in the MANIFEST for every output file, and `VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()` prefers those, so file selection no longer depends on the table format. `ColumnFamilyData::ValidateOptions()` still rejected an explicit value for any other table factory, so `DB::Open()` failed with `NotSupported`.

This change removes that check, so an explicit `periodic_compaction_seconds` works with any table format. The 30-day default still applies only to block-based tables, so other formats see no new compactions unless they set the option. In those formats, a file with no MANIFEST time, such as one written before 6.6, falls back to its modification time, so it may be compacted late but never early. `ttl` keeps its block-based-only check. Bonus: db_stress no longer rejects `--periodic_compaction_seconds` with a non-block-based `--table_factory_uri`.

Differential Revision: D134432323
Summary:
Pull Request resolved: meta#15782

## Summary

`periodic_compaction_seconds` was limited to block-based tables when it was added in RocksDB 6.2 (meta#5166), because file age came from the `file_creation_time` table property, which only the block-based table builder writes. Since RocksDB 6.6, flush and compaction record `file_creation_time` and `oldest_ancester_time` in the MANIFEST for every output file, and `VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()` prefers those, so file selection no longer depends on the table format. `ColumnFamilyData::ValidateOptions()` still rejected an explicit value for any other table factory, so `DB::Open()` failed with `NotSupported`.

This change removes that check, so an explicit `periodic_compaction_seconds` works with any table format. The 30-day default still applies only to block-based tables, so other formats see no new compactions unless they set the option. In those formats, a file with no MANIFEST time, such as one written before 6.6, falls back to its modification time, so it may be compacted late but never early. `ttl` keeps its block-based-only check. Bonus: db_stress no longer rejects `--periodic_compaction_seconds` with a non-block-based `--table_factory_uri`.

Differential Revision: D134432323

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant