Ray's Knowledge Base
Unlock

RocksDB IngestExternalFile costs a reopen and fsync per linked SST, about 3 ms each on NFS

PitfallVerified 23 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

dftracer_index at 48 threads spends about 5 s ingesting 1,124 SSTs (about 4.6 ms each) on /usr/WS2 (NFS), even with move_files=true, write_global_seqno=false and no checksum pass.

Cause#

ExternalSstFileIngestionJob::Prepare links each file, then calls fs_->ReopenWritableFile and fsyncs it, one file at a time, then unlinks the sources in Cleanup, also serially. SstFileWriter::Finish already synced our files. Fewer SSTs is not an option when one SST per key prefix keeps key ranges disjoint (otherwise L0 and global seqno).

Fix#

In our rocksdb::FileSystem wrapper (src/dftracer/utils/index/store/filesystem.cpp) return IOStatus::NotSupported from ReopenWritableFile while an RAII guard (IngestReopenSkip) is alive around the ingest: RocksDB treats NotSupported as "no reopen needed" and skips the fsync. Use link_files=true instead of move_files and unlink the staged names with 16 threads after a successful ingest. Result on minife 8,404 traces: ingest 5.2 s -> 3.0 s, wall 12.1 s -> 9.2 s, index_diff equal on all families.

Evidence#

Corona flux pdebug, 3 alternating rounds HEAD vs new, stage timings from dftracer_index --log-level debug. RocksDB source: db/external_sst_file_ingestion_job.cc lines 160-200. Task TSK-sr10a1, 2026-10-23.