From 8ad2f927b634835f1a7c39fb8cb3d37c1ddc0134 Mon Sep 17 00:00:00 2001 From: ZhiYong Wang Date: Sun, 14 Jun 2020 14:20:23 +0800 Subject: [PATCH] Add skip_memtable_flush in IngestExternalFileOptions Summary: Set to true if you are sure although the key ranges may overlap, the memtable and the file being ingested do not have the same keys, or not care about that. The memtable flushing may block for hundreds of milliseconds. Test Plan: make check --- db/db_impl/db_impl.cc | 4 ++++ include/rocksdb/options.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index c9d7aab3a..c985340bb 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -4253,6 +4253,10 @@ Status DBImpl::IngestExternalFiles( "cannot ingest an external file into a dropped CF"); break; } + if (args[i].options.skip_memtable_flush) { + need_flush[i] = false; + continue; + } bool tmp = false; status = ingestion_jobs[i].NeedsFlush(&tmp, cfd->GetSuperVersion()); need_flush[i] = tmp; diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index 1404031a0..052bd367e 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -1571,6 +1571,11 @@ struct IngestExternalFileOptions { // Using a large readahead size (> 2MB) can typically improve the performance // of forward iteration on spinning disks. size_t verify_checksums_readahead_size = 0; + // Set to true if you are sure although the key ranges may overlap, + // the memtable and the file being ingested + // do not have the same keys, or not care about that. + // The memtable flushing may block for hundreds of milliseconds. + bool skip_memtable_flush = false; }; enum TraceFilterType : uint64_t {