diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index a9cde476ac..48f6529bee 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -3230,6 +3230,8 @@ Status DBImpl::MultiGetImpl( s = Status::Aborted(); break; } + // This could be a long-running operation + ROCKSDB_THREAD_YIELD_HOOK(); } // Post processing (decrement reference counts and record statistics) diff --git a/db/db_iter.cc b/db/db_iter.cc index 97f6f7a076..49537f7011 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -581,6 +581,8 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key, } else { iter_.Next(); } + // This could be a long-running operation due to tombstones, etc. + ROCKSDB_THREAD_YIELD_HOOK(); } while (iter_.Valid()); valid_ = false; diff --git a/port/port.h b/port/port.h index 13aa56d47b..141716e5b9 100644 --- a/port/port.h +++ b/port/port.h @@ -19,3 +19,19 @@ #elif defined(OS_WIN) #include "port/win/port_win.h" #endif + +#ifdef OS_LINUX +// A temporary hook into long-running RocksDB threads to support modifying their +// priority etc. This should become a public API hook once the requirements +// are better understood. +extern "C" void RocksDbThreadYield() __attribute__((__weak__)); +#define ROCKSDB_THREAD_YIELD_HOOK() \ + { \ + if (RocksDbThreadYield) { \ + RocksDbThreadYield(); \ + } \ + } +#else +#define ROCKSDB_THREAD_YIELD_HOOK() \ + {} +#endif