1
0
mirror of https://github.com/facebook/rocksdb.git synced 2026-10-23 08:09:02 +03:00

Rename TableProperties::creation_time to oldest_ancestor_time (#15304)

Summary:
The `creation_time` table property has long stored the file's oldest ancestor time (the oldest key time among the file's ancestors, falling back to flush/compaction time), not the file's creation time, which is `file_creation_time`. A TODO in table_properties.h acknowledged the misleading name. This change starts the API migration: `TableProperties::oldest_ancestor_time` is the new name, and `creation_time` remains as a deprecated alias sharing storage via an anonymous union, so existing external reads and writes continue to compile and behave identically.

An anonymous union is used rather than a `uint64_t&` alias member. A reference member would delete TableProperties copy/move assignment, make the implicit copy constructor bind the copy's alias to the source object (dangling), permit writes through a const TableProperties, add 8 bytes, and break the uint64_t-range walk in TEST_SetRandomTableProperties. The union leaves size, layout, copying, constness, and offsetof unchanged. Reading the other union member is formally UB in ISO C++, but both members are uint64_t and this is supported in practice by GCC, Clang, and MSVC.

All in-repo uses of the old name now use `oldest_ancestor_time`. Names that are externally observable or persisted are intentionally unchanged:
* On-disk property name `rocksdb.creation.time` (`TablePropertiesNames::kCreationTime`)
* The `"creation_time"` key in TableProperties serialization (used by remote compaction)
* The event-log JSON key and `TableProperties::ToString()` label
* Java `TableProperties.getCreationTime()` and C `rocksdb_table_properties_creation_time()`

C API: the auto-binding generator (tools/c_api_gen/auto_simple_bindings.py) only considered direct FieldDecls and failed on the anonymous union's implicit unnamed field. It now treats anonymous union members as direct fields. Regenerating adds a new C getter
`rocksdb_table_properties_oldest_ancestor_time()` alongside the existing `rocksdb_table_properties_creation_time()`.

Follow-up: remove the deprecated `creation_time` alias in a future release.

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

Test Plan: New unit test DBTablePropertiesTest.CreationTimeAliasesOldestAncestorTime verifies the two names share an address and that a write through the old name is visible through the new one. options_settable_test and compaction_service_test cover TableProperties serialization round trips through the unchanged "creation_time" key, now mapped to the renamed field.

Reviewed By: jaykorean

Differential Revision: D123079083

Pulled By: pdillinger

fbshipit-source-id: 18b07d91f303a8f6de58da0c730f80d8c371505c
This commit is contained in:
Peter Dillinger
2026-10-05 10:34:04 -07:00
committed by meta-codesync[bot]
parent c0512c4c34
commit c83a84e98c
23 changed files with 98 additions and 44 deletions

View File

@@ -6973,7 +6973,7 @@ class TablePropertiesJni : public JavaClass {
static_cast<jlong>(table_properties.format_version),
static_cast<jlong>(table_properties.fixed_key_len),
static_cast<jlong>(table_properties.column_family_id),
static_cast<jlong>(table_properties.creation_time),
static_cast<jlong>(table_properties.oldest_ancestor_time),
static_cast<jlong>(table_properties.oldest_key_time),
static_cast<jlong>(
table_properties.slow_compression_estimated_data_size),

View File

@@ -51,7 +51,7 @@ static TableProperties newTablePropertiesForTest() {
table_properties.format_version = UINT64_MAX;
table_properties.fixed_key_len = UINT64_MAX;
table_properties.column_family_id = UINT64_MAX;
table_properties.creation_time = UINT64_MAX;
table_properties.oldest_ancestor_time = UINT64_MAX;
table_properties.oldest_key_time = UINT64_MAX;
table_properties.file_creation_time = UINT64_MAX;
table_properties.slow_compression_estimated_data_size = UINT64_MAX;

View File

@@ -537,10 +537,10 @@ public interface AdvancedMutableColumnFamilyOptionsInterface<
* filters periodically. Users can also use the feature to clear up SST
* files using old format.
* <p>
* A file's age is computed by looking at file_creation_time or creation_time
* table properties in order, if they have valid non-zero values; if not, the
* age is based on the file's last modified time (given by the underlying
* Env).
* A file's age is computed by looking at file_creation_time or
* oldest_ancestor_time table properties in order, if they have valid
* non-zero values; if not, the age is based on the file's last modified time
* (given by the underlying Env).
* <p>
* Supported in Level and FIFO compaction.
* In FIFO compaction, this option has the same meaning as TTL and whichever