rocksdb/db/compaction
Andrew Ryan Chang af2a36d2c7 Record newest_key_time as a table property (#13083)
Summary:
This PR does two things:
1. Adds a new table property `newest_key_time`
2. Uses this property to improve TTL and temperature change compaction.

### Context

The current `creation_time` table property should really be named `oldest_ancestor_time`. For flush output files, this is the oldest key time in the file. For compaction output files, this is the minimum among all oldest key times in the input files.

The problem with using the oldest ancestor time for TTL compaction is that we may end up dropping files earlier than we should. What we really want is the newest (i.e. "youngest") key time. Right now we take a roundabout way to estimate this value -- we take the value of the _oldest_ key time for the _next_ (newer) SST file. This is also why the current code has checks for `index >= 1`.

Our new property `newest_key_time` is set to the file creation time during flushes, and the max over all input files for compactions.

There were some additional smaller changes that I had to make for testing purposes:
- Refactoring the mock table reader to support specifying my own table properties
- Refactoring out a test utility method `GetLevelFileMetadatas`  that would otherwise be copy/pasted in 3 places

Credit to cbi42 for the problem explanation and proposed solution

### Testing

- Added a dedicated unit test to my `newest_key_time` logic in isolation (i.e. are we populating the property on flush and compaction)
- Updated the existing unit tests (for TTL/temperate change compaction), which were comprehensive enough to break when I first made my code changes. I removed the test setup code which set the file metadata `oldest_ancestor_time`, so we know we are actually only using the new table property instead.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/13083

Reviewed By: cbi42

Differential Revision: D65298604

Pulled By: archang19

fbshipit-source-id: 898ef91b692ab33f5129a2a16b64ecadd4c32432
2024-11-01 10:08:35 -07:00
..
clipping_iterator.h Refactor AddRangeDels() + consider range tombstone during compaction file cutting (#11113) 2023-02-22 12:28:18 -08:00
clipping_iterator_test.cc
compaction.cc Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction.h Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction_iteration_stats.h Add initial support for TimedPut API (#12419) 2024-03-14 15:44:55 -07:00
compaction_iterator.cc Add CompactForTieringCollector to support automatically trigger compaction for tiering use case (#12760) 2024-06-18 10:51:29 -07:00
compaction_iterator.h Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_iterator_test.cc Add CompactForTieringCollector to support automatically trigger compaction for tiering use case (#12760) 2024-06-18 10:51:29 -07:00
compaction_job.cc Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction_job.h TableProperties Serialization Follow Ups (#13095) 2024-10-31 11:13:53 -07:00
compaction_job_stats_test.cc Replace ScopedArenaIterator with ScopedArenaPtr<InternalIterator> (#12470) 2024-03-22 13:40:42 -07:00
compaction_job_test.cc Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction_outputs.cc Preserve TimedPut on penultimate level until it actually expires (#12543) 2024-04-30 11:16:02 -07:00
compaction_outputs.h Include TableProperties in the CompactionServiceResult (#13089) 2024-10-25 13:13:12 -07:00
compaction_picker.cc Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker.h Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker_fifo.cc Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction_picker_fifo.h Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker_level.cc Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker_level.h Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker_test.cc Record newest_key_time as a table property (#13083) 2024-11-01 10:08:35 -07:00
compaction_picker_universal.cc Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_picker_universal.h Optimize compaction for standalone range deletion files (#13078) 2024-10-25 09:32:14 -07:00
compaction_service_job.cc TableProperties Serialization Follow Ups (#13095) 2024-10-31 11:13:53 -07:00
compaction_service_test.cc Fix Compaction Stats (#13071) 2024-10-16 19:20:37 -07:00
compaction_state.cc Fix Compaction Stats (#13071) 2024-10-16 19:20:37 -07:00
compaction_state.h
file_pri.h Avoid shifting component too large error in FileTtlBooster (#11673) 2023-08-04 14:29:50 -07:00
sst_partitioner.cc Remove FactoryFunc from LoadXXXObject (#11203) 2023-02-17 12:54:07 -08:00
subcompaction_state.cc Fix Compaction Stats (#13071) 2024-10-16 19:20:37 -07:00
subcompaction_state.h Fix Compaction Stats (#13071) 2024-10-16 19:20:37 -07:00
tiered_compaction_test.cc Fix a bug for surfacing write unix time (#13057) 2024-10-08 11:31:51 -07:00