rocksdb/db/compaction
Yu Zhang f2546b6623 Support returning write unix time in iterator property (#12428)
Summary:
This PR adds support to return data's approximate unix write time in the iterator property API. The general implementation is:
1) If the entry comes from a SST file, the sequence number to time mapping recorded in that file's table properties will be used to deduce the entry's write time from its sequence number. If no such recording is available, `std::numeric_limits<uint64_t>::max()` is returned to indicate the write time is unknown except if the entry's sequence number is zero, in which case, 0 is returned. This also means that even if `preclude_last_level_data_seconds` and `preserve_internal_time_seconds` can be toggled off between DB reopens, as long as the SST file's table property has the mapping available, the entry's write time can be deduced and returned.

2) If the entry comes from memtable, we will use the DB's sequence number to write time mapping to do similar things. A copy of the DB's seqno to write time mapping is kept in SuperVersion to allow iterators to have lock free access. This also means a new `SuperVersion` is installed each time DB's seqno to time mapping updates, which is originally proposed by Peter in  https://github.com/facebook/rocksdb/issues/11928 . Similarly, if the feature is not enabled, `std::numeric_limits<uint64_t>::max()` is returned to indicate the write time is unknown.

Needed follow up:
1) The write time for `kTypeValuePreferredSeqno` should be special cased, where it's already specified by the user, so we can directly return it.

2) Flush job can be updated to use DB's seqno to time mapping copy in the SuperVersion.

3) Handle the case when `TimedPut` is called with a write time that is `std::numeric_limits<uint64_t>::max()`. We can make it a regular `Put`.

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

Test Plan: Added unit test

Reviewed By: pdillinger

Differential Revision: D54967067

Pulled By: jowlyzhang

fbshipit-source-id: c795b1b7ec142e09e53f2ed3461cf719833cb37a
2024-03-15 15:37:37 -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 Print stack traces on frozen tests in CI (#10828) 2022-10-18 00:35:35 -07:00
compaction.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction.h Remove unnecessary, confusing 'extern' (#12300) 2024-01-29 10:38:08 -08:00
compaction_iteration_stats.h Add initial support for TimedPut API (#12419) 2024-03-14 15:44:55 -07:00
compaction_iterator.cc Add initial support for TimedPut API (#12419) 2024-03-14 15:44:55 -07:00
compaction_iterator.h Add initial support for TimedPut API (#12419) 2024-03-14 15:44:55 -07:00
compaction_iterator_test.cc Add initial support for TimedPut API (#12419) 2024-03-14 15:44:55 -07:00
compaction_job.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_job.h Refactor, clean up, fixes, and more testing for SeqnoToTimeMapping (#11905) 2023-09-29 11:21:59 -07:00
compaction_job_stats_test.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_job_test.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_outputs.cc Remove deprecated option level_compaction_dynamic_file_size (#12325) 2024-02-02 15:37:40 -08:00
compaction_outputs.h Removed check_flush_compaction_key_order (#12311) 2024-01-31 16:30:26 -08:00
compaction_picker.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_picker.h Remove deprecated option ignore_max_compaction_bytes_for_input (#12323) 2024-02-02 17:09:42 -08:00
compaction_picker_fifo.cc default_write_temperature option (#12388) 2024-02-28 14:36:13 -08:00
compaction_picker_fifo.h Remove 'virtual' when implied by 'override' (#12319) 2024-01-31 13:14:42 -08:00
compaction_picker_level.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_picker_level.h Remove 'virtual' when implied by 'override' (#12319) 2024-01-31 13:14:42 -08:00
compaction_picker_test.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_picker_universal.cc default_write_temperature option (#12388) 2024-02-28 14:36:13 -08:00
compaction_picker_universal.h Remove 'virtual' when implied by 'override' (#12319) 2024-01-31 13:14:42 -08:00
compaction_service_job.cc Update APIs to support generic unique identifier format (#12384) 2024-03-01 09:55:30 -08:00
compaction_service_test.cc Run internal cpp modernizer on RocksDB repo (#12398) 2024-03-04 10:08:32 -08:00
compaction_state.cc Tiered Compaction: per key placement support (#9964) 2022-07-13 20:54:49 -07:00
compaction_state.h Tiered Compaction: per key placement support (#9964) 2022-07-13 20:54:49 -07:00
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 Refactor Compaction file cut ShouldStopBefore() (#10629) 2022-09-14 22:09:12 -07:00
subcompaction_state.h Refactor AddRangeDels() + consider range tombstone during compaction file cutting (#11113) 2023-02-22 12:28:18 -08:00
tiered_compaction_test.cc Support returning write unix time in iterator property (#12428) 2024-03-15 15:37:37 -07:00