Repository navigation
·
151 commits
to main
since this release
New Features
- Added experimental
SetAsyncReadCPUTimeEnabled(): the next async or coroutine read started on the thread records its CPU time inPerfContext::get_cpu_nanosat any perf level exceptkDisable, without turning on the other timers ofkEnableTimeAndCPUTimeExceptForMutex. - Added
SplitDB(),DeleteSplitRanges(), andMergeDB()inrocksdb/utilities/db_split_merge.h, plus adb_split_mergecommand-line tool, for moving selected column-family key ranges into a new DB and copying ranges into existing column families. - Added opt-in sampled logging of long-held DB-wide mutexes under
StatsLevel::kAll, with a runtime-changeablemutex_hold_log_threshold_usDB option defaulting to 0 (disabled). - Add experimental live tuning of a DB's options (
StartLiveTuneCycle(),GetLiveTuneStatus(),StopLiveTuneCycle()ininclude/rocksdb/live_tune.h): one call runs a cycle that measures the DB, asks an application-providedLiveTuneAdvisorfor option changes, applies them, and reverts them when they break the application's constraints or do not prove better. - Added
CompactionFilter::GetMergeOrder()andCompactionFilterFactory::GetMergeOrder()to optionally run the merge operator before the compaction filter during compaction, so that the filter sees merge results. The default behavior is unchanged. - Parallel compression (
CompressionOptions::parallel_threads > 1) now works with auser_defined_index_factorywhose builders support it, including the built-in trie index. Previously a custom index always forced single-threaded compression. - Added option
reject_too_old_filetoIngestExternalFileOptionsandImportColumnFamilyOptionsto reject files whose data is already older than the column family'speriodic_compaction_seconds(orttlfor FIFO compaction). - Added BlobDB support for remote compaction. Blob garbage collection uses the
cutoff computed by the primary; workers receiving legacy input without a cutoff
safely disable blob garbage collection for that job. When the primary rejects a
remote blob result because its metadata, files, or capabilities fail validation,
it reruns the compaction locally, soCompactRangeandCompactFilessucceed.
CompactionServicekFailuresemantics are unchanged; ZippyDB production also
maps service failures to local fallback throughHandleFailure(FALLBACK_LOCAL). CompactRangeOptions::skip_missing_blob_filesenables offline repair that deletes values referencing integrated external blob files absent from Version metadata, preserves available wide entity columns, and rewrites selected SSTs locally, bypassingDBOptions::compaction_service. It defaults to false; FIFO compaction and legacy BlobDB are unsupported.- Added
db_ownership_start_timeanddata_file_provenance(decoded byDataFileProvenance) toSstFileMetaData, recording when the DB began holding each SST file and how it got the file (e.g. flush, compaction, ingestion, or import). - Added
TableFactory::IsTableBuilderSupported()andExternalTableFactory::IsTableBuilderSupported()for table factories that only read ingested or imported files. A column family whose factory returns false must setdisallow_memtable_writes, is never scheduled for automatic compaction, does not stall writes for L0 files or pending compaction bytes, and returnsNotSupportedfromCompactRange()andCompactFiles()instead of failing a background compaction. - trace_analyzer: new
--analyze_put_entityflag analyzes PutEntity queries (previously their statistics were neither enabled nor disabled explicitly). - Added
TraceOptions::include_read_write_options: query traces can record the mainReadOptionsandWriteOptionsof each traced call (e.g.fill_cache,disableWAL), which replay then uses instead of default options.
Public API Changes
- Added
GetEncodedEntrySize()and anEncodeEntry()overload that writes internal keys into caller-owned buffers without allocating on success. - Added
Env::Priority::READandThreadStatus::READ_PRIORITYfor a dedicated Env-managed read-work thread pool.Env::Priority::USERremains reserved for internal statistics and is not backed by a thread pool. - Added experimental
MultiScanArgs::use_parallel_async_io_block_decompressionfor materializing asynchronously prefetched data blocks, including decompression, in parallel on theEnv::Priority::READthread pool. A zero-sized pool preserves inline materialization. - Added the experimental
IndexFactoryinterface (include/rocksdb/index_factory.h) for pluggable SST indexes; theUserDefinedIndex*names remain as aliases.BlockBasedTableOptions::index_modechooses which indexes an SST is built with and which one reads use by default, superseding the now-deprecateduse_udi_as_primary_indexandfail_if_no_udi_on_open.ReadOptions::read_indexoverrides that choice per read, and thestandard_index_is_stubtable property marks SSTs built withkCustomOnly. Both options are also available in the C API. - Added experimental
DB::GetEntityWithMetadata()andDB::MultiGetEntityWithMetadata(), the wide-column entity counterparts ofDB::GetWithMetadata()andDB::MultiGetWithMetadata()with opt-in explicit-snapshot newer-version detection. Requesting key timestamps returnsNotSupported. - Removed support for building on Solaris, which had not compiled since 5.18. Removed RocksJava
Environment.isSolaris().
Behavior Changes
- With
ReadOptions::async_io,MultiGetnow reads data blocks of direct-IO files with asynchronous reads (FSRandomAccessFile::ReadAsync) instead of a synchronousMultiRead. Each block read is aligned separately rather than merged with adjacent reads. The bytes read are still charged toDBOptions::rate_limiteratReadOptions::rate_limiter_priority. - Asynchronous file reads (
FSRandomAccessFile::ReadAsync, used withReadOptions::async_iobyMultiGetand iterator prefetching) are now charged toDBOptions::rate_limiteratReadOptions::rate_limiter_priority, like synchronous reads. A read is charged once the file system accepts it. CreateColumnFamily()andCreateColumnFamilies()now run the table factory option validation thatDB::Open()runs, so they returnInvalidArgumentinstead of creating a column family that the nextDB::Open()would reject. External table factories wrapped byNewExternalTableFactory()now receiveValidateOptions()calls.- With
CompactionOptionsFIFO::allow_trivial_copy_when_change_temperature, each file copied for a temperature change is now reported toEventListener::OnTableFileCreationStarted()andOnTableFileCreated()(with the original file's table properties) and included inCompactionJobInfo::table_properties. DB::GetMergeOperands()now resets only themerge_operandsentries it fills, instead of allexpected_max_number_of_operandsentries. Entries past*number_of_operands, and the whole array on a non-OK result, are left as the caller passed them.- The JSON written to the info LOG by
EventLogger(EVENT_LOG_v1lines) and byVersionEdit::DebugJSON()now escapes special characters in keys and string values, and writes non-finite floating-point values asnull, so the output is always valid JSON. - Improved how
periodic_compaction_phase_recovery_percentspreads catch-up periodic compactions after it is enabled or changed (or the DB is reopened). This reduces a transient burst in periodic compactions when many DBs make such a change at once. - The new DB option
use_separate_remote_compaction_pooldefaults to false and can be changed throughSetDBOptions()for newly scheduled jobs. When enabled with CompactionService, remote jobs use a dedicated pool and each local subcompaction uses LOW/BOTTOM and counts against the DB compaction limit. Existing jobs finish using their original scheduling model. DB::SetOptions()now returns OK without writing a new OPTIONS file or installing a new SuperVersion when the call changes no option value, asDB::SetDBOptions()already does. Calls that set an object option, such astable_factoryor one of its fields, are still applied in full. After a failed OPTIONS file write, the nextSetOptions()orSetDBOptions()call writes the file even if no option value changes.- Custom index factories are rejected with user-defined timestamps in every index mode except
kStandardOnly, which ignores the factory. Custom-index block-cache hits, misses, and adds now contribute toBLOCK_CACHE_INDEX_*instead ofBLOCK_CACHE_DATA_*.
Trie index construction returnsNotSupportedwhen a data-block offset or size exceedsUINT32_MAX, including when the trie is optional inkStandardDefault. Flush, compaction, andSstFileWriter::Finish()can therefore fail for such output; an SST larger than 4 GiB is not itself the rejection condition. File-size targets do not split L0 outputs orSstFileWriteroutputs. Bound those outputs or disable trie construction withkStandardOnly.
Bug Fixes
- Fixed a race where
IngestExternalFiles()withatomic_replace_rangecould delete an existing SST file that a concurrently picked compaction (e.g. a universal compaction outputting to L0) used as input, causing the compaction to fail with "Corruption: VersionBuilder: Cannot delete table file ... since it is not in the LSM tree" and putting the DB into read-only mode. Atomic range replacement now returnsNotSupportedwith FIFO compaction. - Fixed blob direct write when sealing a blob file fails during a flush or a write: the flush left its memtables marked as being flushed, so no later flush picked them up and error recovery waited for them forever, and the blob file was dropped from tracking, so a retried flush could install table files whose blob file was never added to the MANIFEST.
- Fixed blob direct write with more than one concurrent flush of a column family: a later flush sealed and published the blob files of the oldest pending memtable instead of its own, so flushes failed with
Corruption: VersionBuilder: Blob file #N already addedand the database stopped. - Fixed blob direct write when the
SstFileManagerspace limit is reached while a blob file is sealed: the sealed blob file was deleted while memtables still referenced it, so reads of its values failed and the values were lost, and reporting the error could deadlock with a concurrent memtable switch. The seal and the write or flush now succeed and keep the file, and writes then stop with aSpaceLimitbackground error, so for blob direct write the limit is soft: usage can exceed it by up to aboutblob_file_size×blob_direct_write_partitionsfor each memtable not flushed yet. Also fixed a write batch that failed after writing some of its values to blob files: those blobs are now counted as garbage, so their blob file can still be deleted. - Values that retain external blob references now keep their original timestamps during history compaction, preventing blob key verification failures.
- Fixed
DB::ClipColumnFamily()leaving an empty-string key outside the kept range when it is the only key in an L0 SST file. - Fixed
format_version=8withReverseBytewiseComparator: a block's stored common key prefix could extend past a user key (one following longer user keys that extend it), so reads and iteration could miss that key (or its deletion, exposing an older value), and compactions could fail withCorruption. Files written by affected versions (11.10 through 11.13) are now read correctly, and new files no longer have this problem. - Fixed SST file times that could defer periodic compaction and TTL. Files written by
SstFileWriter, flushed during WAL recovery, or recovered byRepairDBnow record a file creation time. Files added byIngestExternalFile()orCreateColumnFamilyWithImport()now keep the creation and oldest ancestor times from the file or export metadata (capped at the current time) instead of taking the time they were added, so ingesting or importing old data can make it due for periodic compaction or TTL soon afterward. FIFO TTL compaction now also deletes ingestedSstFileWriterfiles, which previously blocked TTL deletion of themselves and all newer files. Files copied by FIFO compaction for a temperature change now keep the original file's creation time. - Fixed a debug-build assertion failure and incorrect cache charge and block-cache byte statistics in release builds when a full, strict-capacity LRU cache with metadata charging creates an uncharged standalone handle, including during secondary-cache promotion.
- Fixed atomic flushes of all column families when another column family is dropped while they wait:
CompactRange()no longer fails with a "Column family dropped" error, andWaitForCompact()and DB close no longer return OK without flushing the remaining column families. - Fixed a bug where MemPurge returned with the DB mutex unlocked when the compaction filter created for flush did not ignore snapshots.
- Fixed a crash in MultiScan
Iterator::Prepare()with a single scan range without a limit when the DB has L0 files, and an assertion failure in debug builds whenPrepare()is called on an already-positioned iterator.Prepare()now leaves the iterator invalid until it is positioned again (e.g. bySeek()). - Fixed
MultiGetreturning NotFound for existing keys that are outside the prefix extractor's domain, with partitioned filters,whole_key_filtering=false, and filter partitions cut together with index partitions (decouple_partitioned_filters=false, also the layout of files written by older versions). A filter partition holding only such keys is empty, andMultiGettreated every key mapped to it as absent.Getwas not affected. - Fixed prepared external file ingestions retaining unrelated obsolete SSTs until commit or abort. Prepared ingestions now protect only their staged files from deletion.
- Fixed data loss with
min_tombstones_for_range_conversionand external file ingestion. An iterator whose view predated the ingestion could convert the deleted keys around the ingested keys into a range tombstone that deleted them. This happened when the file got no new sequence number (sequence number zero,ingest_behind, orallow_db_generated_files), and when an iterator was created during the ingestion. - Fixed a data loss bug where an iterator with
ReadOptions::read_tier = kMemtableTiercould, withmin_tombstones_for_range_conversionenabled, insert a range tombstone that deleted live keys stored only in SST files. Read-path range tombstone conversion now runs only for iterators withread_tier = kReadAllTier. - Fixed a race with
recycle_log_file_num > 0where an obsolete WAL could be reused for a new WAL while its old writer was still open. Closing the old writer then truncated the reused file to the old WAL's size, so writes in the new WAL past that point, including acknowledgedsyncwrites, were lost on the next reopen. - Fixed remote compaction ignoring
preclude_last_level_data_secondsandpreserve_internal_time_seconds, which caused recent data to be written to the last level and recent sequence numbers to be zeroed. Takes effect once both the primary and the compaction worker are upgraded. - Fixed
DB::OpenAndCompact()withOpenAndCompactOptions::allow_resumptionnot callingEventListener::OnSubcompactionCompleted()when the compaction fails to resume from its saved progress. - Fixed MANIFEST catch-up on secondary instances (
TryCatchUpWithPrimary()) and follower instances installing a column family with no files and still returning OK. This happened when catch-up switched to a new MANIFEST and the primary deleted a file that MANIFEST lists before catch-up checked it, recording the deletion in a newer MANIFEST. Catch-up now keeps the column family's previous view until a complete state from the new MANIFEST is available. - Custom index blocks now reuse cached contents on SST reopen, and deprecated UDI boolean options can be cleared without overriding an explicitly configured index mode.
Legacy UDI options copied from a factory can now be cleared before constructing a new factory without retaining the derived mode. The C API preserves both that rollback behavior and explicitly selected modes. OPTIONS files serialize equivalent legacy booleans forkStandardDefault,kStandardRequired, andkCustomDefaultso older readers retain routing.
Empty custom-index output retains the standard-index fallback in modes that write both indexes; custom-only output must remain nonempty. Default primary reads retain the table factory's precedence over a legacy per-read factory pointer, while explicit custom selectors still check its name. - Preserve legacy UDI routing when loading old OPTIONS files, and reject invalid index modes in standalone SST readers and writers. Table readers now charge the custom index blocks they own; a custom reader whose
ApproximateMemoryUsage()already includes that block should overrideIndexFactoryReader::MemoryUsageIncludesIndexBlock()to return true so the block is not charged twice.
Keep cached custom-index Slice views intact when a reader consumes its input. Register custom-index cache helpers without requiring a later change. Trie index size estimates now account for shared prefixes, preventing premature compaction file cuts, and reject data-block offsets or sizes exceeding the 32-bit on-disk limit instead of truncating them.
Performance Improvements
- With
ReadOptions::pin_data, iterators over read-only DBs opened withmax_open_files = -1andallow_mmap_reads = trueno longer accumulate memory as they move across SST files. - On a read-write primary,
DB::GetSnapshot()andDB::ReleaseSnapshot()no longer acquire the DB mutex in the common case. Secondary and follower snapshot creation retains the DB mutex needed to synchronize with view installation, while release remains sharded. The snapshot list is now split into 16 per-CPU shards, each with its own lock, so primary threads creating and releasing snapshots no longer serialize on one lock or wait behind flush, compaction, or other work holding the DB mutex. Snapshot-release maintenance is deferred to existing flush, compaction, and periodic maintenance paths. Primary snapshot creation serializes with the DB-mutex-held phases of external file ingestion but can proceed while the MANIFEST write temporarily releases that mutex.