Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433)

Summary:
When dynamically linking two binaries together, different builds of RocksDB from two sources might cause errors. To provide a tool for user to solve the problem, the RocksDB namespace is changed to a flag which can be overridden in build time.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6433

Test Plan: Build release, all and jtest. Try to build with ROCKSDB_NAMESPACE with another flag.

Differential Revision: D19977691

fbshipit-source-id: aa7f2d0972e1c31d75339ac48478f34f6cfcfb3e
This commit is contained in:
sdong 2020-02-20 12:07:53 -08:00 committed by Facebook Github Bot
parent 4e33f1e1dc
commit fdf882ded2
889 changed files with 9546 additions and 8442 deletions

View File

@ -103,7 +103,7 @@ script:
OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=db_block_cache_test ROCKSDBTESTS_END=db_iter_test make -j4 check_some OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=db_block_cache_test ROCKSDBTESTS_END=db_iter_test make -j4 check_some
;; ;;
2) 2)
OPT=-DTRAVIS V=1 make -j4 tools && OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=db_iter_test ROCKSDBTESTS_END=options_file_test make -j4 check_some OPT="-DTRAVIS -DROCKSDB_NAMESPACE=alternative_rocksdb_ns" V=1 make -j4 tools && OPT="-DTRAVIS -DROCKSDB_NAMESPACE=alternative_rocksdb_ns" V=1 ROCKSDBTESTS_START=db_iter_test ROCKSDBTESTS_END=options_file_test make -j4 check_some
;; ;;
3) 3)
OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=options_file_test ROCKSDBTESTS_END=write_prepared_transaction_test make -j4 check_some OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=options_file_test ROCKSDBTESTS_END=write_prepared_transaction_test make -j4 check_some

View File

@ -23,6 +23,7 @@
### New Features ### New Features
* Added the checksum for each SST file generated by Flush or Compaction. Added sst_file_checksum_func to Options such that user can plugin their own SST file checksum function via override the FileChecksumFunc class. If user does not set the sst_file_checksum_func, SST file checksum calculation will not be enabled. The checksum information inlcuding uint32_t checksum value and a checksum function name (string). The checksum information is stored in FileMetadata in version store and also logged to MANIFEST. A new tool is added to LDB such that user can dump out a list of file checksum information from MANIFEST (stored in an unordered_map). * Added the checksum for each SST file generated by Flush or Compaction. Added sst_file_checksum_func to Options such that user can plugin their own SST file checksum function via override the FileChecksumFunc class. If user does not set the sst_file_checksum_func, SST file checksum calculation will not be enabled. The checksum information inlcuding uint32_t checksum value and a checksum function name (string). The checksum information is stored in FileMetadata in version store and also logged to MANIFEST. A new tool is added to LDB such that user can dump out a list of file checksum information from MANIFEST (stored in an unordered_map).
* `db_bench` now supports `value_size_distribution_type`, `value_size_min`, `value_size_max` options for generating random variable sized value. Added `blob_db_compression_type` option for BlobDB to enable blob compression. * `db_bench` now supports `value_size_distribution_type`, `value_size_min`, `value_size_max` options for generating random variable sized value. Added `blob_db_compression_type` option for BlobDB to enable blob compression.
* Replace RocksDB namespace "rocksdb" with flag "ROCKSDB_NAMESPACE" which if is not defined, defined as "rocksdb".
## 6.7.0 (01/21/2020) ## 6.7.0 (01/21/2020)
### Public API Change ### Public API Change

View File

@ -45,7 +45,7 @@ DEFINE_int32(erase_percent, 10,
DEFINE_bool(use_clock_cache, false, ""); DEFINE_bool(use_clock_cache, false, "");
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CacheBench; class CacheBench;
namespace { namespace {
@ -154,7 +154,7 @@ class CacheBench {
} }
bool Run() { bool Run() {
rocksdb::Env* env = rocksdb::Env::Default(); ROCKSDB_NAMESPACE::Env* env = ROCKSDB_NAMESPACE::Env::Default();
PrintEnv(); PrintEnv();
SharedState shared(this); SharedState shared(this);
@ -257,7 +257,7 @@ class CacheBench {
printf("----------------------------\n"); printf("----------------------------\n");
} }
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
ParseCommandLineFlags(&argc, &argv, true); ParseCommandLineFlags(&argc, &argv, true);
@ -267,7 +267,7 @@ int main(int argc, char** argv) {
exit(1); exit(1);
} }
rocksdb::CacheBench bench; ROCKSDB_NAMESPACE::CacheBench bench;
if (FLAGS_populate_cache) { if (FLAGS_populate_cache) {
bench.PopulateCache(); bench.PopulateCache();
} }

4
cache/cache_test.cc vendored
View File

@ -20,7 +20,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Conversions between numeric keys/values and the types expected by Cache. // Conversions between numeric keys/values and the types expected by Cache.
static std::string EncodeKey(int k) { static std::string EncodeKey(int k) {
@ -765,7 +765,7 @@ INSTANTIATE_TEST_CASE_P(CacheTestInstance, CacheTest, testing::Values(kLRU));
#endif // SUPPORT_CLOCK_CACHE #endif // SUPPORT_CLOCK_CACHE
INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest, testing::Values(kLRU)); INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest, testing::Values(kLRU));
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -11,7 +11,7 @@
#ifndef SUPPORT_CLOCK_CACHE #ifndef SUPPORT_CLOCK_CACHE
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
std::shared_ptr<Cache> NewClockCache( std::shared_ptr<Cache> NewClockCache(
size_t /*capacity*/, int /*num_shard_bits*/, bool /*strict_capacity_limit*/, size_t /*capacity*/, int /*num_shard_bits*/, bool /*strict_capacity_limit*/,
@ -20,7 +20,7 @@ std::shared_ptr<Cache> NewClockCache(
return nullptr; return nullptr;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#else #else
@ -41,7 +41,7 @@ std::shared_ptr<Cache> NewClockCache(
#include "util/autovector.h" #include "util/autovector.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
@ -756,6 +756,6 @@ std::shared_ptr<Cache> NewClockCache(
capacity, num_shard_bits, strict_capacity_limit, metadata_charge_policy); capacity, num_shard_bits, strict_capacity_limit, metadata_charge_policy);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // SUPPORT_CLOCK_CACHE #endif // SUPPORT_CLOCK_CACHE

4
cache/lru_cache.cc vendored
View File

@ -16,7 +16,7 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
LRUHandleTable::LRUHandleTable() : list_(nullptr), length_(0), elems_(0) { LRUHandleTable::LRUHandleTable() : list_(nullptr), length_(0), elems_(0) {
Resize(); Resize();
@ -571,4 +571,4 @@ std::shared_ptr<Cache> NewLRUCache(
std::move(memory_allocator), use_adaptive_mutex, metadata_charge_policy); std::move(memory_allocator), use_adaptive_mutex, metadata_charge_policy);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

4
cache/lru_cache.h vendored
View File

@ -16,7 +16,7 @@
#include "port/port.h" #include "port/port.h"
#include "util/autovector.h" #include "util/autovector.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// LRU cache implementation. This class is not thread-safe. // LRU cache implementation. This class is not thread-safe.
@ -336,4 +336,4 @@ class LRUCache
int num_shards_ = 0; int num_shards_ = 0;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -10,7 +10,7 @@
#include "port/port.h" #include "port/port.h"
#include "test_util/testharness.h" #include "test_util/testharness.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class LRUCacheTest : public testing::Test { class LRUCacheTest : public testing::Test {
public: public:
@ -190,7 +190,7 @@ TEST_F(LRUCacheTest, EntriesWithPriority) {
ValidateLRUList({"e", "f", "g", "Z", "d"}, 2); ValidateLRUList({"e", "f", "g", "Z", "d"}, 2);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -13,7 +13,7 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
ShardedCache::ShardedCache(size_t capacity, int num_shard_bits, ShardedCache::ShardedCache(size_t capacity, int num_shard_bits,
bool strict_capacity_limit, bool strict_capacity_limit,
@ -159,4 +159,4 @@ int GetDefaultCacheShardBits(size_t capacity) {
return num_shard_bits; return num_shard_bits;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -16,7 +16,7 @@
#include "rocksdb/cache.h" #include "rocksdb/cache.h"
#include "util/hash.h" #include "util/hash.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Single cache shard interface. // Single cache shard interface.
class CacheShard { class CacheShard {
@ -108,4 +108,4 @@ class ShardedCache : public Cache {
extern int GetDefaultCacheShardBits(size_t capacity); extern int GetDefaultCacheShardBits(size_t capacity);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -16,7 +16,7 @@
#include "table/iterator_wrapper.h" #include "table/iterator_wrapper.h"
#include "util/user_comparator_wrapper.h" #include "util/user_comparator_wrapper.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
Status ArenaWrappedDBIter::GetProperty(std::string prop_name, Status ArenaWrappedDBIter::GetProperty(std::string prop_name,
std::string* prop) { std::string* prop) {
@ -103,4 +103,4 @@ ArenaWrappedDBIter* NewArenaWrappedDbIterator(
return iter; return iter;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -20,7 +20,7 @@
#include "rocksdb/iterator.h" #include "rocksdb/iterator.h"
#include "util/autovector.h" #include "util/autovector.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class Arena; class Arena;
@ -109,4 +109,4 @@ extern ArenaWrappedDBIter* NewArenaWrappedDbIterator(
ReadCallback* read_callback, DBImpl* db_impl = nullptr, ReadCallback* read_callback, DBImpl* db_impl = nullptr,
ColumnFamilyData* cfd = nullptr, bool allow_blob = false, ColumnFamilyData* cfd = nullptr, bool allow_blob = false,
bool allow_refresh = true); bool allow_refresh = true);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -12,7 +12,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// BlobIndex is a pointer to the blob and metadata of the blob. The index is // BlobIndex is a pointer to the blob and metadata of the blob. The index is
// stored in base DB as ValueType::kTypeBlobIndex. // stored in base DB as ValueType::kTypeBlobIndex.
@ -175,5 +175,5 @@ class BlobIndex {
CompressionType compression_ = kNoCompression; CompressionType compression_ = kNoCompression;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

View File

@ -37,7 +37,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/stop_watch.h" #include "util/stop_watch.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class TableFactory; class TableFactory;
@ -260,4 +260,4 @@ Status BuildTable(
return s; return s;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -22,7 +22,7 @@
#include "rocksdb/types.h" #include "rocksdb/types.h"
#include "table/scoped_arena_iterator.h" #include "table/scoped_arena_iterator.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
struct Options; struct Options;
struct FileMetaData; struct FileMetaData;
@ -85,4 +85,4 @@ extern Status BuildTable(
Env::WriteLifeTimeHint write_hint = Env::WLTH_NOT_SET, Env::WriteLifeTimeHint write_hint = Env::WLTH_NOT_SET,
const uint64_t file_creation_time = 0); const uint64_t file_creation_time = 0);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

215
db/c.cc
View File

@ -46,74 +46,74 @@
#include <unordered_set> #include <unordered_set>
#include <map> #include <map>
using rocksdb::BytewiseComparator; using ROCKSDB_NAMESPACE::BackupableDBOptions;
using rocksdb::Cache; using ROCKSDB_NAMESPACE::BackupEngine;
using rocksdb::ColumnFamilyDescriptor; using ROCKSDB_NAMESPACE::BackupID;
using rocksdb::ColumnFamilyHandle; using ROCKSDB_NAMESPACE::BackupInfo;
using rocksdb::ColumnFamilyOptions; using ROCKSDB_NAMESPACE::BatchResult;
using rocksdb::CompactionFilter; using ROCKSDB_NAMESPACE::BlockBasedTableOptions;
using rocksdb::CompactionFilterFactory; using ROCKSDB_NAMESPACE::BottommostLevelCompaction;
using rocksdb::CompactionFilterContext; using ROCKSDB_NAMESPACE::BytewiseComparator;
using rocksdb::CompactionOptionsFIFO; using ROCKSDB_NAMESPACE::Cache;
using rocksdb::Comparator; using ROCKSDB_NAMESPACE::Checkpoint;
using rocksdb::CompressionType; using ROCKSDB_NAMESPACE::ColumnFamilyDescriptor;
using rocksdb::WALRecoveryMode; using ROCKSDB_NAMESPACE::ColumnFamilyHandle;
using rocksdb::DB; using ROCKSDB_NAMESPACE::ColumnFamilyOptions;
using rocksdb::DBOptions; using ROCKSDB_NAMESPACE::CompactionFilter;
using rocksdb::DbPath; using ROCKSDB_NAMESPACE::CompactionFilterContext;
using rocksdb::Env; using ROCKSDB_NAMESPACE::CompactionFilterFactory;
using rocksdb::EnvOptions; using ROCKSDB_NAMESPACE::CompactionOptionsFIFO;
using rocksdb::InfoLogLevel; using ROCKSDB_NAMESPACE::CompactRangeOptions;
using rocksdb::FileLock; using ROCKSDB_NAMESPACE::Comparator;
using rocksdb::FilterPolicy; using ROCKSDB_NAMESPACE::CompressionType;
using rocksdb::FlushOptions; using ROCKSDB_NAMESPACE::CuckooTableOptions;
using rocksdb::IngestExternalFileOptions; using ROCKSDB_NAMESPACE::DB;
using rocksdb::Iterator; using ROCKSDB_NAMESPACE::DBOptions;
using rocksdb::Logger; using ROCKSDB_NAMESPACE::DbPath;
using rocksdb::MergeOperator; using ROCKSDB_NAMESPACE::Env;
using rocksdb::MergeOperators; using ROCKSDB_NAMESPACE::EnvOptions;
using rocksdb::NewBloomFilterPolicy; using ROCKSDB_NAMESPACE::FileLock;
using rocksdb::NewLRUCache; using ROCKSDB_NAMESPACE::FilterPolicy;
using rocksdb::Options; using ROCKSDB_NAMESPACE::FlushOptions;
using rocksdb::BlockBasedTableOptions; using ROCKSDB_NAMESPACE::InfoLogLevel;
using rocksdb::CuckooTableOptions; using ROCKSDB_NAMESPACE::IngestExternalFileOptions;
using rocksdb::RandomAccessFile; using ROCKSDB_NAMESPACE::Iterator;
using rocksdb::Range; using ROCKSDB_NAMESPACE::LiveFileMetaData;
using rocksdb::ReadOptions; using ROCKSDB_NAMESPACE::Logger;
using rocksdb::SequentialFile; using ROCKSDB_NAMESPACE::MemoryUtil;
using rocksdb::Slice; using ROCKSDB_NAMESPACE::MergeOperator;
using rocksdb::SliceParts; using ROCKSDB_NAMESPACE::MergeOperators;
using rocksdb::SliceTransform; using ROCKSDB_NAMESPACE::NewBloomFilterPolicy;
using rocksdb::Snapshot; using ROCKSDB_NAMESPACE::NewGenericRateLimiter;
using rocksdb::SstFileWriter; using ROCKSDB_NAMESPACE::NewLRUCache;
using rocksdb::Status; using ROCKSDB_NAMESPACE::OptimisticTransactionDB;
using rocksdb::WritableFile; using ROCKSDB_NAMESPACE::OptimisticTransactionOptions;
using rocksdb::WriteBatch; using ROCKSDB_NAMESPACE::Options;
using rocksdb::WriteBatchWithIndex; using ROCKSDB_NAMESPACE::PerfContext;
using rocksdb::WriteOptions; using ROCKSDB_NAMESPACE::PerfLevel;
using rocksdb::LiveFileMetaData; using ROCKSDB_NAMESPACE::PinnableSlice;
using rocksdb::BackupEngine; using ROCKSDB_NAMESPACE::RandomAccessFile;
using rocksdb::BackupableDBOptions; using ROCKSDB_NAMESPACE::Range;
using rocksdb::BackupInfo; using ROCKSDB_NAMESPACE::RateLimiter;
using rocksdb::BackupID; using ROCKSDB_NAMESPACE::ReadOptions;
using rocksdb::RestoreOptions; using ROCKSDB_NAMESPACE::RestoreOptions;
using rocksdb::CompactRangeOptions; using ROCKSDB_NAMESPACE::SequentialFile;
using rocksdb::BottommostLevelCompaction; using ROCKSDB_NAMESPACE::Slice;
using rocksdb::RateLimiter; using ROCKSDB_NAMESPACE::SliceParts;
using rocksdb::NewGenericRateLimiter; using ROCKSDB_NAMESPACE::SliceTransform;
using rocksdb::PinnableSlice; using ROCKSDB_NAMESPACE::Snapshot;
using rocksdb::TransactionDBOptions; using ROCKSDB_NAMESPACE::SstFileWriter;
using rocksdb::TransactionDB; using ROCKSDB_NAMESPACE::Status;
using rocksdb::TransactionOptions; using ROCKSDB_NAMESPACE::Transaction;
using rocksdb::OptimisticTransactionDB; using ROCKSDB_NAMESPACE::TransactionDB;
using rocksdb::OptimisticTransactionOptions; using ROCKSDB_NAMESPACE::TransactionDBOptions;
using rocksdb::Transaction; using ROCKSDB_NAMESPACE::TransactionLogIterator;
using rocksdb::Checkpoint; using ROCKSDB_NAMESPACE::TransactionOptions;
using rocksdb::TransactionLogIterator; using ROCKSDB_NAMESPACE::WALRecoveryMode;
using rocksdb::BatchResult; using ROCKSDB_NAMESPACE::WritableFile;
using rocksdb::PerfLevel; using ROCKSDB_NAMESPACE::WriteBatch;
using rocksdb::PerfContext; using ROCKSDB_NAMESPACE::WriteBatchWithIndex;
using rocksdb::MemoryUtil; using ROCKSDB_NAMESPACE::WriteOptions;
using std::shared_ptr; using std::shared_ptr;
using std::vector; using std::vector;
@ -452,7 +452,7 @@ struct rocksdb_slicetransform_t : public SliceTransform {
}; };
struct rocksdb_universal_compaction_options_t { struct rocksdb_universal_compaction_options_t {
rocksdb::CompactionOptionsUniversal *rep; ROCKSDB_NAMESPACE::CompactionOptionsUniversal* rep;
}; };
static bool SaveError(char** errptr, const Status& s) { static bool SaveError(char** errptr, const Status& s) {
@ -494,8 +494,9 @@ rocksdb_t* rocksdb_open_with_ttl(
const char* name, const char* name,
int ttl, int ttl,
char** errptr) { char** errptr) {
rocksdb::DBWithTTL* db; ROCKSDB_NAMESPACE::DBWithTTL* db;
if (SaveError(errptr, rocksdb::DBWithTTL::Open(options->rep, std::string(name), &db, ttl))) { if (SaveError(errptr, ROCKSDB_NAMESPACE::DBWithTTL::Open(
options->rep, std::string(name), &db, ttl))) {
return nullptr; return nullptr;
} }
rocksdb_t* result = new rocksdb_t; rocksdb_t* result = new rocksdb_t;
@ -664,7 +665,8 @@ void rocksdb_close(rocksdb_t* db) {
} }
void rocksdb_options_set_uint64add_merge_operator(rocksdb_options_t* opt) { void rocksdb_options_set_uint64add_merge_operator(rocksdb_options_t* opt) {
opt->rep.merge_operator = rocksdb::MergeOperators::CreateUInt64AddOperator(); opt->rep.merge_operator =
ROCKSDB_NAMESPACE::MergeOperators::CreateUInt64AddOperator();
} }
rocksdb_t* rocksdb_open_column_families( rocksdb_t* rocksdb_open_column_families(
@ -2078,7 +2080,7 @@ void rocksdb_options_set_block_based_table_factory(
rocksdb_block_based_table_options_t* table_options) { rocksdb_block_based_table_options_t* table_options) {
if (table_options) { if (table_options) {
opt->rep.table_factory.reset( opt->rep.table_factory.reset(
rocksdb::NewBlockBasedTableFactory(table_options->rep)); ROCKSDB_NAMESPACE::NewBlockBasedTableFactory(table_options->rep));
} }
} }
@ -2122,7 +2124,7 @@ void rocksdb_options_set_cuckoo_table_factory(
rocksdb_cuckoo_table_options_t* table_options) { rocksdb_cuckoo_table_options_t* table_options) {
if (table_options) { if (table_options) {
opt->rep.table_factory.reset( opt->rep.table_factory.reset(
rocksdb::NewCuckooTableFactory(table_options->rep)); ROCKSDB_NAMESPACE::NewCuckooTableFactory(table_options->rep));
} }
} }
@ -2312,7 +2314,7 @@ void rocksdb_options_set_max_bytes_for_level_multiplier_additional(
} }
void rocksdb_options_enable_statistics(rocksdb_options_t* opt) { void rocksdb_options_enable_statistics(rocksdb_options_t* opt) {
opt->rep.statistics = rocksdb::CreateDBStatistics(); opt->rep.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
} }
void rocksdb_options_set_skip_stats_update_on_db_open(rocksdb_options_t* opt, void rocksdb_options_set_skip_stats_update_on_db_open(rocksdb_options_t* opt,
@ -2468,16 +2470,20 @@ void rocksdb_options_set_access_hint_on_compaction_start(
rocksdb_options_t* opt, int v) { rocksdb_options_t* opt, int v) {
switch(v) { switch(v) {
case 0: case 0:
opt->rep.access_hint_on_compaction_start = rocksdb::Options::NONE; opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::NONE;
break; break;
case 1: case 1:
opt->rep.access_hint_on_compaction_start = rocksdb::Options::NORMAL; opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::NORMAL;
break; break;
case 2: case 2:
opt->rep.access_hint_on_compaction_start = rocksdb::Options::SEQUENTIAL; opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::SEQUENTIAL;
break; break;
case 3: case 3:
opt->rep.access_hint_on_compaction_start = rocksdb::Options::WILLNEED; opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::WILLNEED;
break; break;
} }
} }
@ -2643,7 +2649,7 @@ void rocksdb_options_prepare_for_bulk_load(rocksdb_options_t* opt) {
} }
void rocksdb_options_set_memtable_vector_rep(rocksdb_options_t *opt) { void rocksdb_options_set_memtable_vector_rep(rocksdb_options_t *opt) {
opt->rep.memtable_factory.reset(new rocksdb::VectorRepFactory); opt->rep.memtable_factory.reset(new ROCKSDB_NAMESPACE::VectorRepFactory);
} }
void rocksdb_options_set_memtable_prefix_bloom_size_ratio( void rocksdb_options_set_memtable_prefix_bloom_size_ratio(
@ -2659,26 +2665,29 @@ void rocksdb_options_set_memtable_huge_page_size(rocksdb_options_t* opt,
void rocksdb_options_set_hash_skip_list_rep( void rocksdb_options_set_hash_skip_list_rep(
rocksdb_options_t *opt, size_t bucket_count, rocksdb_options_t *opt, size_t bucket_count,
int32_t skiplist_height, int32_t skiplist_branching_factor) { int32_t skiplist_height, int32_t skiplist_branching_factor) {
rocksdb::MemTableRepFactory* factory = rocksdb::NewHashSkipListRepFactory( ROCKSDB_NAMESPACE::MemTableRepFactory* factory =
bucket_count, skiplist_height, skiplist_branching_factor); ROCKSDB_NAMESPACE::NewHashSkipListRepFactory(
bucket_count, skiplist_height, skiplist_branching_factor);
opt->rep.memtable_factory.reset(factory); opt->rep.memtable_factory.reset(factory);
} }
void rocksdb_options_set_hash_link_list_rep( void rocksdb_options_set_hash_link_list_rep(
rocksdb_options_t *opt, size_t bucket_count) { rocksdb_options_t *opt, size_t bucket_count) {
opt->rep.memtable_factory.reset(rocksdb::NewHashLinkListRepFactory(bucket_count)); opt->rep.memtable_factory.reset(
ROCKSDB_NAMESPACE::NewHashLinkListRepFactory(bucket_count));
} }
void rocksdb_options_set_plain_table_factory( void rocksdb_options_set_plain_table_factory(
rocksdb_options_t *opt, uint32_t user_key_len, int bloom_bits_per_key, rocksdb_options_t *opt, uint32_t user_key_len, int bloom_bits_per_key,
double hash_table_ratio, size_t index_sparseness) { double hash_table_ratio, size_t index_sparseness) {
rocksdb::PlainTableOptions options; ROCKSDB_NAMESPACE::PlainTableOptions options;
options.user_key_len = user_key_len; options.user_key_len = user_key_len;
options.bloom_bits_per_key = bloom_bits_per_key; options.bloom_bits_per_key = bloom_bits_per_key;
options.hash_table_ratio = hash_table_ratio; options.hash_table_ratio = hash_table_ratio;
options.index_sparseness = index_sparseness; options.index_sparseness = index_sparseness;
rocksdb::TableFactory* factory = rocksdb::NewPlainTableFactory(options); ROCKSDB_NAMESPACE::TableFactory* factory =
ROCKSDB_NAMESPACE::NewPlainTableFactory(options);
opt->rep.table_factory.reset(factory); opt->rep.table_factory.reset(factory);
} }
@ -2708,7 +2717,8 @@ void rocksdb_options_set_report_bg_io_stats(
} }
void rocksdb_options_set_compaction_style(rocksdb_options_t *opt, int style) { void rocksdb_options_set_compaction_style(rocksdb_options_t *opt, int style) {
opt->rep.compaction_style = static_cast<rocksdb::CompactionStyle>(style); opt->rep.compaction_style =
static_cast<ROCKSDB_NAMESPACE::CompactionStyle>(style);
} }
void rocksdb_options_set_universal_compaction_options(rocksdb_options_t *opt, rocksdb_universal_compaction_options_t *uco) { void rocksdb_options_set_universal_compaction_options(rocksdb_options_t *opt, rocksdb_universal_compaction_options_t *uco) {
@ -2722,7 +2732,7 @@ void rocksdb_options_set_fifo_compaction_options(
} }
char *rocksdb_options_statistics_get_string(rocksdb_options_t *opt) { char *rocksdb_options_statistics_get_string(rocksdb_options_t *opt) {
rocksdb::Statistics *statistics = opt->rep.statistics.get(); ROCKSDB_NAMESPACE::Statistics* statistics = opt->rep.statistics.get();
if (statistics) { if (statistics) {
return strdup(statistics->ToString().c_str()); return strdup(statistics->ToString().c_str());
} }
@ -2762,7 +2772,7 @@ void rocksdb_set_perf_level(int v) {
rocksdb_perfcontext_t* rocksdb_perfcontext_create() { rocksdb_perfcontext_t* rocksdb_perfcontext_create() {
rocksdb_perfcontext_t* context = new rocksdb_perfcontext_t; rocksdb_perfcontext_t* context = new rocksdb_perfcontext_t;
context->rep = rocksdb::get_perf_context(); context->rep = ROCKSDB_NAMESPACE::get_perf_context();
return context; return context;
} }
@ -3064,11 +3074,12 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom_format(int bits_per_ke
return rep_->KeyMayMatch(key, filter); return rep_->KeyMayMatch(key, filter);
} }
// No need to override GetFilterBitsBuilder if this one is overridden // No need to override GetFilterBitsBuilder if this one is overridden
rocksdb::FilterBitsBuilder* GetBuilderWithContext( ROCKSDB_NAMESPACE::FilterBitsBuilder* GetBuilderWithContext(
const rocksdb::FilterBuildingContext& context) const override { const ROCKSDB_NAMESPACE::FilterBuildingContext& context)
const override {
return rep_->GetBuilderWithContext(context); return rep_->GetBuilderWithContext(context);
} }
rocksdb::FilterBitsReader* GetFilterBitsReader( ROCKSDB_NAMESPACE::FilterBitsReader* GetFilterBitsReader(
const Slice& contents) const override { const Slice& contents) const override {
return rep_->GetFilterBitsReader(contents); return rep_->GetFilterBitsReader(contents);
} }
@ -3170,7 +3181,7 @@ void rocksdb_readoptions_set_iterate_lower_bound(
void rocksdb_readoptions_set_read_tier( void rocksdb_readoptions_set_read_tier(
rocksdb_readoptions_t* opt, int v) { rocksdb_readoptions_t* opt, int v) {
opt->rep.read_tier = static_cast<rocksdb::ReadTier>(v); opt->rep.read_tier = static_cast<ROCKSDB_NAMESPACE::ReadTier>(v);
} }
void rocksdb_readoptions_set_tailing( void rocksdb_readoptions_set_tailing(
@ -3342,7 +3353,7 @@ rocksdb_env_t* rocksdb_create_default_env() {
rocksdb_env_t* rocksdb_create_mem_env() { rocksdb_env_t* rocksdb_create_mem_env() {
rocksdb_env_t* result = new rocksdb_env_t; rocksdb_env_t* result = new rocksdb_env_t;
result->rep = rocksdb::NewMemEnv(Env::Default()); result->rep = ROCKSDB_NAMESPACE::NewMemEnv(Env::Default());
result->is_default = false; result->is_default = false;
return result; return result;
} }
@ -3557,7 +3568,7 @@ struct Wrapper : public rocksdb_slicetransform_t {
rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t prefixLen) { rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t prefixLen) {
Wrapper* wrapper = new Wrapper; Wrapper* wrapper = new Wrapper;
wrapper->rep_ = rocksdb::NewFixedPrefixTransform(prefixLen); wrapper->rep_ = ROCKSDB_NAMESPACE::NewFixedPrefixTransform(prefixLen);
wrapper->state_ = nullptr; wrapper->state_ = nullptr;
wrapper->destructor_ = &Wrapper::DoNothing; wrapper->destructor_ = &Wrapper::DoNothing;
return wrapper; return wrapper;
@ -3565,7 +3576,7 @@ rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t pref
rocksdb_slicetransform_t* rocksdb_slicetransform_create_noop() { rocksdb_slicetransform_t* rocksdb_slicetransform_create_noop() {
Wrapper* wrapper = new Wrapper; Wrapper* wrapper = new Wrapper;
wrapper->rep_ = rocksdb::NewNoopTransform(); wrapper->rep_ = ROCKSDB_NAMESPACE::NewNoopTransform();
wrapper->state_ = nullptr; wrapper->state_ = nullptr;
wrapper->destructor_ = &Wrapper::DoNothing; wrapper->destructor_ = &Wrapper::DoNothing;
return wrapper; return wrapper;
@ -3573,7 +3584,7 @@ rocksdb_slicetransform_t* rocksdb_slicetransform_create_noop() {
rocksdb_universal_compaction_options_t* rocksdb_universal_compaction_options_create() { rocksdb_universal_compaction_options_t* rocksdb_universal_compaction_options_create() {
rocksdb_universal_compaction_options_t* result = new rocksdb_universal_compaction_options_t; rocksdb_universal_compaction_options_t* result = new rocksdb_universal_compaction_options_t;
result->rep = new rocksdb::CompactionOptionsUniversal; result->rep = new ROCKSDB_NAMESPACE::CompactionOptionsUniversal;
return result; return result;
} }
@ -3604,7 +3615,8 @@ void rocksdb_universal_compaction_options_set_compression_size_percent(
void rocksdb_universal_compaction_options_set_stop_style( void rocksdb_universal_compaction_options_set_stop_style(
rocksdb_universal_compaction_options_t* uco, int style) { rocksdb_universal_compaction_options_t* uco, int style) {
uco->rep->stop_style = static_cast<rocksdb::CompactionStopStyle>(style); uco->rep->stop_style =
static_cast<ROCKSDB_NAMESPACE::CompactionStopStyle>(style);
} }
void rocksdb_universal_compaction_options_destroy( void rocksdb_universal_compaction_options_destroy(
@ -3634,7 +3646,7 @@ void rocksdb_options_set_min_level_to_compress(rocksdb_options_t* opt, int level
assert(level <= opt->rep.num_levels); assert(level <= opt->rep.num_levels);
opt->rep.compression_per_level.resize(opt->rep.num_levels); opt->rep.compression_per_level.resize(opt->rep.num_levels);
for (int i = 0; i < level; i++) { for (int i = 0; i < level; i++) {
opt->rep.compression_per_level[i] = rocksdb::kNoCompression; opt->rep.compression_per_level[i] = ROCKSDB_NAMESPACE::kNoCompression;
} }
for (int i = level; i < opt->rep.num_levels; i++) { for (int i = level; i < opt->rep.num_levels; i++) {
opt->rep.compression_per_level[i] = opt->rep.compression; opt->rep.compression_per_level[i] = opt->rep.compression;
@ -4336,7 +4348,8 @@ const char* rocksdb_pinnableslice_value(const rocksdb_pinnableslice_t* v,
return v->rep.data(); return v->rep.data();
} }
// container to keep databases and caches in order to use rocksdb::MemoryUtil // container to keep databases and caches in order to use
// ROCKSDB_NAMESPACE::MemoryUtil
struct rocksdb_memory_consumers_t { struct rocksdb_memory_consumers_t {
std::vector<rocksdb_t*> dbs; std::vector<rocksdb_t*> dbs;
std::unordered_set<rocksdb_cache_t*> caches; std::unordered_set<rocksdb_cache_t*> caches;
@ -4364,7 +4377,7 @@ void rocksdb_memory_consumers_destroy(rocksdb_memory_consumers_t* consumers) {
delete consumers; delete consumers;
} }
// contains memory usage statistics provided by rocksdb::MemoryUtil // contains memory usage statistics provided by ROCKSDB_NAMESPACE::MemoryUtil
struct rocksdb_memory_usage_t { struct rocksdb_memory_usage_t {
uint64_t mem_table_total; uint64_t mem_table_total;
uint64_t mem_table_unflushed; uint64_t mem_table_unflushed;
@ -4386,7 +4399,7 @@ rocksdb_memory_usage_t* rocksdb_approximate_memory_usage_create(
cache_set.insert(const_cast<const Cache*>(cache->rep.get())); cache_set.insert(const_cast<const Cache*>(cache->rep.get()));
} }
std::map<rocksdb::MemoryUtil::UsageType, uint64_t> usage_by_type; std::map<ROCKSDB_NAMESPACE::MemoryUtil::UsageType, uint64_t> usage_by_type;
auto status = MemoryUtil::GetApproximateMemoryUsageByType(dbs, cache_set, auto status = MemoryUtil::GetApproximateMemoryUsageByType(dbs, cache_set,
&usage_by_type); &usage_by_type);

View File

@ -36,7 +36,7 @@
#include "util/autovector.h" #include "util/autovector.h"
#include "util/compression.h" #include "util/compression.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
ColumnFamilyHandleImpl::ColumnFamilyHandleImpl( ColumnFamilyHandleImpl::ColumnFamilyHandleImpl(
ColumnFamilyData* column_family_data, DBImpl* db, InstrumentedMutex* mutex) ColumnFamilyData* column_family_data, DBImpl* db, InstrumentedMutex* mutex)
@ -1520,4 +1520,4 @@ const Comparator* GetColumnFamilyUserComparator(
return nullptr; return nullptr;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -27,7 +27,7 @@
#include "trace_replay/block_cache_tracer.h" #include "trace_replay/block_cache_tracer.h"
#include "util/thread_local.h" #include "util/thread_local.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class Version; class Version;
class VersionSet; class VersionSet;
@ -754,4 +754,4 @@ extern uint32_t GetColumnFamilyID(ColumnFamilyHandle* column_family);
extern const Comparator* GetColumnFamilyUserComparator( extern const Comparator* GetColumnFamilyUserComparator(
ColumnFamilyHandle* column_family); ColumnFamilyHandle* column_family);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -30,7 +30,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static const int kValueSize = 1000; static const int kValueSize = 1000;
@ -91,7 +91,7 @@ class ColumnFamilyTestBase : public testing::Test {
column_families.push_back(cfdescriptor); column_families.push_back(cfdescriptor);
} }
Close(); Close();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Destroy(column_families); Destroy(column_families);
delete env_; delete env_;
} }
@ -595,14 +595,15 @@ TEST_P(ColumnFamilyTest, DontReuseColumnFamilyID) {
TEST_P(ColumnFamilyTest, CreateCFRaceWithGetAggProperty) { TEST_P(ColumnFamilyTest, CreateCFRaceWithGetAggProperty) {
Open(); Open();
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WriteOptionsFile:1", {{"DBImpl::WriteOptionsFile:1",
"ColumnFamilyTest.CreateCFRaceWithGetAggProperty:1"}, "ColumnFamilyTest.CreateCFRaceWithGetAggProperty:1"},
{"ColumnFamilyTest.CreateCFRaceWithGetAggProperty:2", {"ColumnFamilyTest.CreateCFRaceWithGetAggProperty:2",
"DBImpl::WriteOptionsFile:2"}}); "DBImpl::WriteOptionsFile:2"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([&] { CreateColumnFamilies({"one"}); }); ROCKSDB_NAMESPACE::port::Thread thread(
[&] { CreateColumnFamilies({"one"}); });
TEST_SYNC_POINT("ColumnFamilyTest.CreateCFRaceWithGetAggProperty:1"); TEST_SYNC_POINT("ColumnFamilyTest.CreateCFRaceWithGetAggProperty:1");
uint64_t pv; uint64_t pv;
@ -611,7 +612,7 @@ TEST_P(ColumnFamilyTest, CreateCFRaceWithGetAggProperty) {
thread.join(); thread.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
@ -1253,13 +1254,14 @@ TEST_P(ColumnFamilyTest, DifferentWriteBufferSizes) {
// #endif // !ROCKSDB_LITE // #endif // !ROCKSDB_LITE
class TestComparator : public Comparator { class TestComparator : public Comparator {
int Compare(const rocksdb::Slice& /*a*/, int Compare(const ROCKSDB_NAMESPACE::Slice& /*a*/,
const rocksdb::Slice& /*b*/) const override { const ROCKSDB_NAMESPACE::Slice& /*b*/) const override {
return 0; return 0;
} }
const char* Name() const override { return "Test"; } const char* Name() const override { return "Test"; }
void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(
const rocksdb::Slice& /*limit*/) const override {} std::string* /*start*/,
const ROCKSDB_NAMESPACE::Slice& /*limit*/) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
@ -1427,11 +1429,11 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(ToString(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::MultiManual:4", "ColumnFamilyTest::MultiManual:1"}, {{"ColumnFamilyTest::MultiManual:4", "ColumnFamilyTest::MultiManual:1"},
{"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:5"}, {"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:5"},
{"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:3"}}); {"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::MultiManual:4"); TEST_SYNC_POINT("ColumnFamilyTest::MultiManual:4");
@ -1440,7 +1442,7 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<port::Thread> threads; std::vector<port::Thread> threads;
threads.emplace_back([&] { threads.emplace_back([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
@ -1483,8 +1485,8 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
Close(); Close();
} }
@ -1523,11 +1525,11 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
dbfull()->TEST_write_controler().GetCompactionPressureToken(); dbfull()->TEST_write_controler().GetCompactionPressureToken();
bool cf_1_1 = true; bool cf_1_1 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:1"}, {{"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:1"},
{"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:5"}, {"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:5"},
{"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:3"}}); {"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
cf_1_1 = false; cf_1_1 = false;
@ -1535,7 +1537,7 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:3"); TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:3");
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// SETUP column family "one" -- universal style // SETUP column family "one" -- universal style
for (int i = 0; i < one.level0_file_num_compaction_trigger; ++i) { for (int i = 0; i < one.level0_file_num_compaction_trigger; ++i) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
@ -1553,7 +1555,7 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
WaitForFlush(2); WaitForFlush(2);
AssertFilesPerLevel(ToString(i + 1), 2); AssertFilesPerLevel(ToString(i + 1), 2);
} }
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
ASSERT_OK( ASSERT_OK(
@ -1580,8 +1582,8 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) { TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
@ -1627,11 +1629,11 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:1"}, {{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:1"},
{"ColumnFamilyTest::ManualAuto:5", "ColumnFamilyTest::ManualAuto:2"}, {"ColumnFamilyTest::ManualAuto:5", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:2", "ColumnFamilyTest::ManualAuto:3"}}); {"ColumnFamilyTest::ManualAuto:2", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
@ -1643,8 +1645,8 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
ASSERT_OK( ASSERT_OK(
@ -1679,8 +1681,8 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) { TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
@ -1721,13 +1723,13 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::ManualManual:4", "ColumnFamilyTest::ManualManual:2"}, {{"ColumnFamilyTest::ManualManual:4", "ColumnFamilyTest::ManualManual:2"},
{"ColumnFamilyTest::ManualManual:4", "ColumnFamilyTest::ManualManual:5"}, {"ColumnFamilyTest::ManualManual:4", "ColumnFamilyTest::ManualManual:5"},
{"ColumnFamilyTest::ManualManual:1", "ColumnFamilyTest::ManualManual:2"}, {"ColumnFamilyTest::ManualManual:1", "ColumnFamilyTest::ManualManual:2"},
{"ColumnFamilyTest::ManualManual:1", {"ColumnFamilyTest::ManualManual:1",
"ColumnFamilyTest::ManualManual:3"}}); "ColumnFamilyTest::ManualManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualManual:4"); TEST_SYNC_POINT("ColumnFamilyTest::ManualManual:4");
@ -1739,8 +1741,8 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = true; compact_options.exclusive_manual_compaction = true;
ASSERT_OK( ASSERT_OK(
@ -1760,7 +1762,7 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
1); 1);
} }
rocksdb::port::Thread threads1([&] { ROCKSDB_NAMESPACE::port::Thread threads1([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
ASSERT_OK( ASSERT_OK(
@ -1781,8 +1783,8 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) { TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
@ -1823,12 +1825,12 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:2"}, {{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:5"}, {"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:5"},
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:2"}, {"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}}); {"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
@ -1840,8 +1842,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
ASSERT_OK( ASSERT_OK(
@ -1874,8 +1876,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) { TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
@ -1916,14 +1918,14 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:2"}, {{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:5"}, {"ColumnFamilyTest::ManualAuto:4", "ColumnFamilyTest::ManualAuto:5"},
{"ColumnFamilyTest::ManualAuto:3", "ColumnFamilyTest::ManualAuto:2"}, {"ColumnFamilyTest::ManualAuto:3", "ColumnFamilyTest::ManualAuto:2"},
{"LevelCompactionPicker::PickCompactionBySize:0", {"LevelCompactionPicker::PickCompactionBySize:0",
"ColumnFamilyTest::ManualAuto:3"}, "ColumnFamilyTest::ManualAuto:3"},
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}}); {"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
@ -1935,8 +1937,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
ASSERT_OK( ASSERT_OK(
@ -1967,8 +1969,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
// In this test, we generate enough files to trigger automatic compactions. // In this test, we generate enough files to trigger automatic compactions.
@ -2008,12 +2010,12 @@ TEST_P(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:2"}, {{"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:2"},
{"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:5"}, {"ColumnFamilyTest::AutoManual:4", "ColumnFamilyTest::AutoManual:5"},
{"CompactionPicker::CompactRange:Conflict", {"CompactionPicker::CompactRange:Conflict",
"ColumnFamilyTest::AutoManual:3"}}); "ColumnFamilyTest::AutoManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) { if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:4"); TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:4");
@ -2025,7 +2027,7 @@ TEST_P(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// SETUP column family "one" -- universal style // SETUP column family "one" -- universal style
for (int i = 0; i < one.level0_file_num_compaction_trigger; ++i) { for (int i = 0; i < one.level0_file_num_compaction_trigger; ++i) {
@ -2059,8 +2061,8 @@ TEST_P(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
ASSERT_NE("NOT_FOUND", Get(1, *key_iter)); ASSERT_NE("NOT_FOUND", Get(1, *key_iter));
key_iter++; key_iter++;
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
@ -2415,7 +2417,7 @@ TEST_P(ColumnFamilyTest, FlushAndDropRaceCondition) {
options.write_buffer_size = 100000; // small write buffer size options.write_buffer_size = 100000; // small write buffer size
Reopen({options, options}); Reopen({options, options});
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"VersionSet::LogAndApply::ColumnFamilyDrop:0", {{"VersionSet::LogAndApply::ColumnFamilyDrop:0",
"FlushJob::WriteLevel0Table"}, "FlushJob::WriteLevel0Table"},
{"VersionSet::LogAndApply::ColumnFamilyDrop:1", {"VersionSet::LogAndApply::ColumnFamilyDrop:1",
@ -2423,7 +2425,7 @@ TEST_P(ColumnFamilyTest, FlushAndDropRaceCondition) {
{"FlushJob::InstallResults", {"FlushJob::InstallResults",
"VersionSet::LogAndApply::ColumnFamilyDrop:2"}}); "VersionSet::LogAndApply::ColumnFamilyDrop:2"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
test::SleepingBackgroundTask sleeping_task; test::SleepingBackgroundTask sleeping_task;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task, env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task,
@ -2502,21 +2504,21 @@ TEST_P(ColumnFamilyTest, CreateAndDropRace) {
auto main_thread_id = std::this_thread::get_id(); auto main_thread_id = std::this_thread::get_id();
rocksdb::SyncPoint::GetInstance()->SetCallBack("PersistRocksDBOptions:start", ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
[&](void* /*arg*/) { "PersistRocksDBOptions:start", [&](void* /*arg*/) {
auto current_thread_id = std::this_thread::get_id(); auto current_thread_id = std::this_thread::get_id();
// If it's the main thread hitting this sync-point, then it // If it's the main thread hitting this sync-point, then it
// will be blocked until some other thread update the test_stage. // will be blocked until some other thread update the test_stage.
if (main_thread_id == current_thread_id) { if (main_thread_id == current_thread_id) {
test_stage = kMainThreadStartPersistingOptionsFile; test_stage = kMainThreadStartPersistingOptionsFile;
while (test_stage < kChildThreadFinishDroppingColumnFamily && while (test_stage < kChildThreadFinishDroppingColumnFamily &&
!ordered_by_writethread) { !ordered_by_writethread) {
Env::Default()->SleepForMicroseconds(100); Env::Default()->SleepForMicroseconds(100);
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WriteThread::EnterUnbatched:Wait", [&](void* /*arg*/) { "WriteThread::EnterUnbatched:Wait", [&](void* /*arg*/) {
// This means a thread doing DropColumnFamily() is waiting for // This means a thread doing DropColumnFamily() is waiting for
// other thread to finish persisting options. // other thread to finish persisting options.
@ -2528,12 +2530,12 @@ TEST_P(ColumnFamilyTest, CreateAndDropRace) {
Open({"default", "one", "two", "three"}, Open({"default", "one", "two", "three"},
{cf_opts[0], cf_opts[1], cf_opts[2], cf_opts[3]}); {cf_opts[0], cf_opts[1], cf_opts[2], cf_opts[3]});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Start a thread that will drop the first column family // Start a thread that will drop the first column family
// and its comparator // and its comparator
rocksdb::port::Thread drop_cf_thread(DropSingleColumnFamily, this, 1, ROCKSDB_NAMESPACE::port::Thread drop_cf_thread(DropSingleColumnFamily, this,
&comparators); 1, &comparators);
DropColumnFamilies({2}); DropColumnFamilies({2});
@ -2546,8 +2548,8 @@ TEST_P(ColumnFamilyTest, CreateAndDropRace) {
} }
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
@ -2982,10 +2984,10 @@ TEST_P(ColumnFamilyTest, FlushCloseWALFiles) {
ASSERT_OK(Put(0, "fodor", "mirko")); ASSERT_OK(Put(0, "fodor", "mirko"));
ASSERT_OK(Put(1, "fodor", "mirko")); ASSERT_OK(Put(1, "fodor", "mirko"));
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBImpl::BGWorkFlush:done", "FlushCloseWALFiles:0"}, {"DBImpl::BGWorkFlush:done", "FlushCloseWALFiles:0"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Block flush jobs from running // Block flush jobs from running
test::SleepingBackgroundTask sleeping_task; test::SleepingBackgroundTask sleeping_task;
@ -3001,7 +3003,7 @@ TEST_P(ColumnFamilyTest, FlushCloseWALFiles) {
sleeping_task.WakeUp(); sleeping_task.WakeUp();
sleeping_task.WaitUntilDone(); sleeping_task.WaitUntilDone();
TEST_SYNC_POINT("FlushCloseWALFiles:0"); TEST_SYNC_POINT("FlushCloseWALFiles:0");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(1, env.num_open_wal_file_.load()); ASSERT_EQ(1, env.num_open_wal_file_.load());
Reopen(); Reopen();
@ -3079,14 +3081,14 @@ TEST_P(ColumnFamilyTest, IteratorCloseWALFile2) {
ASSERT_OK(Put(0, "fodor", "mirko")); ASSERT_OK(Put(0, "fodor", "mirko"));
ASSERT_OK(Put(1, "fodor", "mirko")); ASSERT_OK(Put(1, "fodor", "mirko"));
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"ColumnFamilyTest::IteratorCloseWALFile2:0", {"ColumnFamilyTest::IteratorCloseWALFile2:0",
"DBImpl::BGWorkPurge:start"}, "DBImpl::BGWorkPurge:start"},
{"ColumnFamilyTest::IteratorCloseWALFile2:2", {"ColumnFamilyTest::IteratorCloseWALFile2:2",
"DBImpl::BackgroundCallFlush:start"}, "DBImpl::BackgroundCallFlush:start"},
{"DBImpl::BGWorkPurge:end", "ColumnFamilyTest::IteratorCloseWALFile2:1"}, {"DBImpl::BGWorkPurge:end", "ColumnFamilyTest::IteratorCloseWALFile2:1"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = true; wo.sync = true;
@ -3104,7 +3106,7 @@ TEST_P(ColumnFamilyTest, IteratorCloseWALFile2) {
TEST_SYNC_POINT("ColumnFamilyTest::IteratorCloseWALFile2:2"); TEST_SYNC_POINT("ColumnFamilyTest::IteratorCloseWALFile2:2");
WaitForFlush(1); WaitForFlush(1);
ASSERT_EQ(1, env.num_open_wal_file_.load()); ASSERT_EQ(1, env.num_open_wal_file_.load());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Reopen(); Reopen();
ASSERT_EQ("mirko", Get(0, "fodor")); ASSERT_EQ("mirko", Get(0, "fodor"));
@ -3148,14 +3150,14 @@ TEST_P(ColumnFamilyTest, ForwardIteratorCloseWALFile) {
ASSERT_OK(Put(0, "fodor", "mirko")); ASSERT_OK(Put(0, "fodor", "mirko"));
ASSERT_OK(Put(1, "fodor", "mirko")); ASSERT_OK(Put(1, "fodor", "mirko"));
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"ColumnFamilyTest::IteratorCloseWALFile2:0", {"ColumnFamilyTest::IteratorCloseWALFile2:0",
"DBImpl::BGWorkPurge:start"}, "DBImpl::BGWorkPurge:start"},
{"ColumnFamilyTest::IteratorCloseWALFile2:2", {"ColumnFamilyTest::IteratorCloseWALFile2:2",
"DBImpl::BackgroundCallFlush:start"}, "DBImpl::BackgroundCallFlush:start"},
{"DBImpl::BGWorkPurge:end", "ColumnFamilyTest::IteratorCloseWALFile2:1"}, {"DBImpl::BGWorkPurge:end", "ColumnFamilyTest::IteratorCloseWALFile2:1"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = true; wo.sync = true;
@ -3179,7 +3181,7 @@ TEST_P(ColumnFamilyTest, ForwardIteratorCloseWALFile) {
ASSERT_EQ(1, env.delete_count_.load()); ASSERT_EQ(1, env.delete_count_.load());
delete it; delete it;
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Reopen(); Reopen();
ASSERT_EQ("mirko", Get(0, "fodor")); ASSERT_EQ("mirko", Get(0, "fodor"));
@ -3199,15 +3201,15 @@ TEST_P(ColumnFamilyTest, LogSyncConflictFlush) {
Put(0, "", ""); Put(0, "", "");
Put(1, "foo", "bar"); Put(1, "foo", "bar");
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::SyncWAL:BeforeMarkLogsSynced:1", {{"DBImpl::SyncWAL:BeforeMarkLogsSynced:1",
"ColumnFamilyTest::LogSyncConflictFlush:1"}, "ColumnFamilyTest::LogSyncConflictFlush:1"},
{"ColumnFamilyTest::LogSyncConflictFlush:2", {"ColumnFamilyTest::LogSyncConflictFlush:2",
"DBImpl::SyncWAL:BeforeMarkLogsSynced:2"}}); "DBImpl::SyncWAL:BeforeMarkLogsSynced:2"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([&] { db_->SyncWAL(); }); ROCKSDB_NAMESPACE::port::Thread thread([&] { db_->SyncWAL(); });
TEST_SYNC_POINT("ColumnFamilyTest::LogSyncConflictFlush:1"); TEST_SYNC_POINT("ColumnFamilyTest::LogSyncConflictFlush:1");
Flush(1); Flush(1);
@ -3218,7 +3220,7 @@ TEST_P(ColumnFamilyTest, LogSyncConflictFlush) {
thread.join(); thread.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Close(); Close();
} }
#endif #endif
@ -3367,7 +3369,7 @@ TEST_P(ColumnFamilyTest, MultipleCFPathsTest) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
extern "C" { extern "C" {
@ -3378,7 +3380,7 @@ void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
#endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
RegisterCustomObjects(argc, argv); RegisterCustomObjects(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -18,7 +18,7 @@
#include "test_util/testharness.h" #include "test_util/testharness.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CompactFilesTest : public testing::Test { class CompactFilesTest : public testing::Test {
public: public:
@ -81,11 +81,11 @@ TEST_F(CompactFilesTest, L0ConflictsFiles) {
assert(s.ok()); assert(s.ok());
assert(db); assert(db);
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"CompactFilesImpl:0", "BackgroundCallCompaction:0"}, {"CompactFilesImpl:0", "BackgroundCallCompaction:0"},
{"BackgroundCallCompaction:1", "CompactFilesImpl:1"}, {"BackgroundCallCompaction:1", "CompactFilesImpl:1"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// create couple files // create couple files
// Background compaction starts and waits in BackgroundCallCompaction:0 // Background compaction starts and waits in BackgroundCallCompaction:0
@ -95,7 +95,7 @@ TEST_F(CompactFilesTest, L0ConflictsFiles) {
db->Flush(FlushOptions()); db->Flush(FlushOptions());
} }
rocksdb::ColumnFamilyMetaData meta; ROCKSDB_NAMESPACE::ColumnFamilyMetaData meta;
db->GetColumnFamilyMetaData(&meta); db->GetColumnFamilyMetaData(&meta);
std::string file1; std::string file1;
for (auto& file : meta.levels[0].files) { for (auto& file : meta.levels[0].files) {
@ -108,12 +108,12 @@ TEST_F(CompactFilesTest, L0ConflictsFiles) {
// The background compaction then notices that there is an L0 compaction // The background compaction then notices that there is an L0 compaction
// already in progress and doesn't do an L0 compaction // already in progress and doesn't do an L0 compaction
// Once the background compaction finishes, the compact files finishes // Once the background compaction finishes, the compact files finishes
ASSERT_OK( ASSERT_OK(db->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(),
db->CompactFiles(rocksdb::CompactionOptions(), {file1, file2}, 0)); {file1, file2}, 0));
break; break;
} }
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
delete db; delete db;
} }
@ -224,14 +224,14 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
auto l0_files = collector->GetFlushedFiles(); auto l0_files = collector->GetFlushedFiles();
EXPECT_EQ(5, l0_files.size()); EXPECT_EQ(5, l0_files.size());
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"CompactFilesImpl:2", "CompactFilesTest.CapturingPendingFiles:0"}, {"CompactFilesImpl:2", "CompactFilesTest.CapturingPendingFiles:0"},
{"CompactFilesTest.CapturingPendingFiles:1", "CompactFilesImpl:3"}, {"CompactFilesTest.CapturingPendingFiles:1", "CompactFilesImpl:3"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Start compacting files. // Start compacting files.
rocksdb::port::Thread compaction_thread( ROCKSDB_NAMESPACE::port::Thread compaction_thread(
[&] { EXPECT_OK(db->CompactFiles(CompactionOptions(), l0_files, 1)); }); [&] { EXPECT_OK(db->CompactFiles(CompactionOptions(), l0_files, 1)); });
// In the meantime flush another file. // In the meantime flush another file.
@ -242,7 +242,7 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
compaction_thread.join(); compaction_thread.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
delete db; delete db;
@ -296,12 +296,12 @@ TEST_F(CompactFilesTest, CompactionFilterWithGetSv) {
db->Flush(FlushOptions()); db->Flush(FlushOptions());
// Compact all L0 files using CompactFiles // Compact all L0 files using CompactFiles
rocksdb::ColumnFamilyMetaData meta; ROCKSDB_NAMESPACE::ColumnFamilyMetaData meta;
db->GetColumnFamilyMetaData(&meta); db->GetColumnFamilyMetaData(&meta);
for (auto& file : meta.levels[0].files) { for (auto& file : meta.levels[0].files) {
std::string fname = file.db_path + "/" + file.name; std::string fname = file.db_path + "/" + file.name;
ASSERT_OK( ASSERT_OK(
db->CompactFiles(rocksdb::CompactionOptions(), {fname}, 0)); db->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(), {fname}, 0));
} }
@ -347,7 +347,7 @@ TEST_F(CompactFilesTest, SentinelCompressionType) {
compaction_opts.compression = CompressionType::kDisableCompressionOption; compaction_opts.compression = CompressionType::kDisableCompressionOption;
ASSERT_OK(db->CompactFiles(compaction_opts, l0_files, 1)); ASSERT_OK(db->CompactFiles(compaction_opts, l0_files, 1));
rocksdb::TablePropertiesCollection all_tables_props; ROCKSDB_NAMESPACE::TablePropertiesCollection all_tables_props;
ASSERT_OK(db->GetPropertiesOfAllTables(&all_tables_props)); ASSERT_OK(db->GetPropertiesOfAllTables(&all_tables_props));
for (const auto& name_and_table_props : all_tables_props) { for (const auto& name_and_table_props : all_tables_props) {
ASSERT_EQ(CompressionTypeToString(CompressionType::kZlibCompression), ASSERT_EQ(CompressionTypeToString(CompressionType::kZlibCompression),
@ -402,7 +402,7 @@ TEST_F(CompactFilesTest, GetCompactionJobInfo) {
delete db; delete db;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -9,7 +9,7 @@
#include "db/version_set.h" #include "db/version_set.h"
#include "table/get_context.h" #include "table/get_context.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
extern void MarkKeyMayExist(void* arg); extern void MarkKeyMayExist(void* arg);
extern bool SaveValue(void* arg, const ParsedInternalKey& parsed_key, extern bool SaveValue(void* arg, const ParsedInternalKey& parsed_key,
@ -156,5 +156,5 @@ Status CompactedDBImpl::Open(const Options& options,
return s; return s;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

View File

@ -9,7 +9,7 @@
#include <vector> #include <vector>
#include "db/db_impl/db_impl.h" #include "db/db_impl/db_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CompactedDBImpl : public DBImpl { class CompactedDBImpl : public DBImpl {
public: public:
@ -109,5 +109,5 @@ class CompactedDBImpl : public DBImpl {
const Comparator* user_comparator_; const Comparator* user_comparator_;
LevelFilesBrief files_; LevelFilesBrief files_;
}; };
} } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

View File

@ -16,7 +16,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
const uint64_t kRangeTombstoneSentinel = const uint64_t kRangeTombstoneSentinel =
PackSequenceAndType(kMaxSequenceNumber, kTypeRangeDeletion); PackSequenceAndType(kMaxSequenceNumber, kTypeRangeDeletion);
@ -561,4 +561,4 @@ int Compaction::GetInputBaseLevel() const {
return input_vstorage_->base_level(); return input_vstorage_->base_level();
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -13,7 +13,7 @@
#include "options/cf_options.h" #include "options/cf_options.h"
#include "util/autovector.h" #include "util/autovector.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// The file contains class Compaction, as well as some helper functions // The file contains class Compaction, as well as some helper functions
// and data structures used by the class. // and data structures used by the class.
@ -381,4 +381,4 @@ class Compaction {
// Return sum of sizes of all files in `files`. // Return sum of sizes of all files in `files`.
extern uint64_t TotalFileSize(const std::vector<FileMetaData*>& files); extern uint64_t TotalFileSize(const std::vector<FileMetaData*>& files);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -5,6 +5,8 @@
#pragma once #pragma once
#include "rocksdb/rocksdb_namespace.h"
struct CompactionIterationStats { struct CompactionIterationStats {
// Compaction statistics // Compaction statistics

View File

@ -28,7 +28,7 @@
((seq) <= earliest_snapshot_ && \ ((seq) <= earliest_snapshot_ && \
(snapshot_checker_ == nullptr || LIKELY(IsInEarliestSnapshot(seq)))) (snapshot_checker_ == nullptr || LIKELY(IsInEarliestSnapshot(seq))))
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
CompactionIterator::CompactionIterator( CompactionIterator::CompactionIterator(
InternalIterator* input, const Comparator* cmp, MergeHelper* merge_helper, InternalIterator* input, const Comparator* cmp, MergeHelper* merge_helper,
@ -771,4 +771,4 @@ bool CompactionIterator::IsInEarliestSnapshot(SequenceNumber sequence) {
return in_snapshot == SnapshotCheckerResult::kInSnapshot; return in_snapshot == SnapshotCheckerResult::kInSnapshot;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -19,7 +19,7 @@
#include "options/cf_options.h" #include "options/cf_options.h"
#include "rocksdb/compaction_filter.h" #include "rocksdb/compaction_filter.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CompactionIterator { class CompactionIterator {
public: public:
@ -237,4 +237,4 @@ class CompactionIterator {
manual_compaction_paused_->load(std::memory_order_relaxed); manual_compaction_paused_->load(std::memory_order_relaxed);
} }
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -14,7 +14,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Expects no merging attempts. // Expects no merging attempts.
class NoMergingMergeOp : public MergeOperator { class NoMergingMergeOp : public MergeOperator {
@ -494,7 +494,7 @@ TEST_P(CompactionIteratorTest, ShuttingDownInFilter) {
compaction_proxy_->key_not_exists_beyond_output_level = true; compaction_proxy_->key_not_exists_beyond_output_level = true;
std::atomic<bool> seek_done{false}; std::atomic<bool> seek_done{false};
rocksdb::port::Thread compaction_thread([&] { ROCKSDB_NAMESPACE::port::Thread compaction_thread([&] {
c_iter_->SeekToFirst(); c_iter_->SeekToFirst();
EXPECT_FALSE(c_iter_->Valid()); EXPECT_FALSE(c_iter_->Valid());
EXPECT_TRUE(c_iter_->status().IsShutdownInProgress()); EXPECT_TRUE(c_iter_->status().IsShutdownInProgress());
@ -531,7 +531,7 @@ TEST_P(CompactionIteratorTest, ShuttingDownInMerge) {
compaction_proxy_->key_not_exists_beyond_output_level = true; compaction_proxy_->key_not_exists_beyond_output_level = true;
std::atomic<bool> seek_done{false}; std::atomic<bool> seek_done{false};
rocksdb::port::Thread compaction_thread([&] { ROCKSDB_NAMESPACE::port::Thread compaction_thread([&] {
c_iter_->SeekToFirst(); c_iter_->SeekToFirst();
ASSERT_FALSE(c_iter_->Valid()); ASSERT_FALSE(c_iter_->Valid());
ASSERT_TRUE(c_iter_->status().IsShutdownInProgress()); ASSERT_TRUE(c_iter_->status().IsShutdownInProgress());
@ -968,7 +968,7 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, CompactionFilter_FullMerge) {
compaction_filter.get()); compaction_filter.get());
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -59,7 +59,7 @@
#include "util/stop_watch.h" #include "util/stop_watch.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
const char* GetCompactionReasonString(CompactionReason compaction_reason) { const char* GetCompactionReasonString(CompactionReason compaction_reason) {
switch (compaction_reason) { switch (compaction_reason) {
@ -1697,4 +1697,4 @@ void CompactionJob::LogCompaction() {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -44,7 +44,7 @@
#include "util/stop_watch.h" #include "util/stop_watch.h"
#include "util/thread_local.h" #include "util/thread_local.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class Arena; class Arena;
class ErrorHandler; class ErrorHandler;
@ -195,4 +195,4 @@ class CompactionJob {
Env::Priority thread_pri_; Env::Priority thread_pri_;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -61,7 +61,7 @@
#if !defined(IOS_CROSS_COMPILE) #if !defined(IOS_CROSS_COMPILE)
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static std::string RandomString(Random* rnd, int len, double ratio) { static std::string RandomString(Random* rnd, int len, double ratio) {
std::string r; std::string r;
@ -110,9 +110,9 @@ class CompactionJobStatsTest : public testing::Test,
} }
~CompactionJobStatsTest() override { ~CompactionJobStatsTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({}); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
Close(); Close();
Options options; Options options;
options.db_paths.emplace_back(dbname_, 0); options.db_paths.emplace_back(dbname_, 0);
@ -801,7 +801,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
stats_checker->set_verify_next_comp_io_stats(true); stats_checker->set_verify_next_comp_io_stats(true);
std::atomic<bool> first_prepare_write(true); std::atomic<bool> first_prepare_write(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::Append:BeforePrepareWrite", [&](void* /*arg*/) { "WritableFileWriter::Append:BeforePrepareWrite", [&](void* /*arg*/) {
if (first_prepare_write.load()) { if (first_prepare_write.load()) {
options.env->SleepForMicroseconds(3); options.env->SleepForMicroseconds(3);
@ -810,7 +810,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
}); });
std::atomic<bool> first_flush(true); std::atomic<bool> first_flush(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::Flush:BeforeAppend", [&](void* /*arg*/) { "WritableFileWriter::Flush:BeforeAppend", [&](void* /*arg*/) {
if (first_flush.load()) { if (first_flush.load()) {
options.env->SleepForMicroseconds(3); options.env->SleepForMicroseconds(3);
@ -819,7 +819,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
}); });
std::atomic<bool> first_sync(true); std::atomic<bool> first_sync(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::SyncInternal:0", [&](void* /*arg*/) { "WritableFileWriter::SyncInternal:0", [&](void* /*arg*/) {
if (first_sync.load()) { if (first_sync.load()) {
options.env->SleepForMicroseconds(3); options.env->SleepForMicroseconds(3);
@ -828,14 +828,14 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
}); });
std::atomic<bool> first_range_sync(true); std::atomic<bool> first_range_sync(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { "WritableFileWriter::RangeSync:0", [&](void* /*arg*/) {
if (first_range_sync.load()) { if (first_range_sync.load()) {
options.env->SleepForMicroseconds(3); options.env->SleepForMicroseconds(3);
first_range_sync.store(false); first_range_sync.store(false);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Compact(1, smallest_key, largest_key); Compact(1, smallest_key, largest_key);
@ -844,7 +844,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
ASSERT_TRUE(!first_flush.load()); ASSERT_TRUE(!first_flush.load());
ASSERT_TRUE(!first_sync.load()); ASSERT_TRUE(!first_sync.load());
ASSERT_TRUE(!first_range_sync.load()); ASSERT_TRUE(!first_range_sync.load());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
ASSERT_EQ(stats_checker->NumberOfUnverifiedStats(), 0U); ASSERT_EQ(stats_checker->NumberOfUnverifiedStats(), 0U);
} }
@ -1019,10 +1019,10 @@ TEST_P(CompactionJobStatsTest, UniversalCompactionTest) {
INSTANTIATE_TEST_CASE_P(CompactionJobStatsTest, CompactionJobStatsTest, INSTANTIATE_TEST_CASE_P(CompactionJobStatsTest, CompactionJobStatsTest,
::testing::Values(1, 4)); ::testing::Values(1, 4));
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -29,7 +29,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
@ -1063,7 +1063,7 @@ TEST_F(CompactionJobTest, OldestBlobFileNumber) {
/* expected_oldest_blob_file_number */ 19); /* expected_oldest_blob_file_number */ 19);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -23,7 +23,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files) { uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files) {
@ -1128,4 +1128,4 @@ bool CompactionPicker::GetOverlappingL0Files(
return true; return true;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -22,7 +22,7 @@
#include "rocksdb/options.h" #include "rocksdb/options.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// The file contains an abstract class CompactionPicker, and its two // The file contains an abstract class CompactionPicker, and its two
// sub-classes LevelCompactionPicker and NullCompactionPicker, as // sub-classes LevelCompactionPicker and NullCompactionPicker, as
@ -310,4 +310,4 @@ CompressionOptions GetCompressionOptions(const ImmutableCFOptions& ioptions,
int level, int level,
const bool enable_compression = true); const bool enable_compression = true);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -17,7 +17,7 @@
#include "logging/log_buffer.h" #include "logging/log_buffer.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
uint64_t GetTotalFilesSize(const std::vector<FileMetaData*>& files) { uint64_t GetTotalFilesSize(const std::vector<FileMetaData*>& files) {
uint64_t total_size = 0; uint64_t total_size = 0;
@ -238,5 +238,5 @@ Compaction* FIFOCompactionPicker::CompactRange(
return c; return c;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -12,7 +12,7 @@
#include "db/compaction/compaction_picker.h" #include "db/compaction/compaction_picker.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class FIFOCompactionPicker : public CompactionPicker { class FIFOCompactionPicker : public CompactionPicker {
public: public:
FIFOCompactionPicker(const ImmutableCFOptions& ioptions, FIFOCompactionPicker(const ImmutableCFOptions& ioptions,
@ -49,5 +49,5 @@ class FIFOCompactionPicker : public CompactionPicker {
VersionStorageInfo* version, VersionStorageInfo* version,
LogBuffer* log_buffer); LogBuffer* log_buffer);
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -15,7 +15,7 @@
#include "logging/log_buffer.h" #include "logging/log_buffer.h"
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
bool LevelCompactionPicker::NeedsCompaction( bool LevelCompactionPicker::NeedsCompaction(
const VersionStorageInfo* vstorage) const { const VersionStorageInfo* vstorage) const {
@ -555,4 +555,4 @@ Compaction* LevelCompactionPicker::PickCompaction(
log_buffer, mutable_cf_options, ioptions_); log_buffer, mutable_cf_options, ioptions_);
return builder.PickCompaction(); return builder.PickCompaction();
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -11,7 +11,7 @@
#include "db/compaction/compaction_picker.h" #include "db/compaction/compaction_picker.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Picking compactions for leveled compaction. See wiki page // Picking compactions for leveled compaction. See wiki page
// https://github.com/facebook/rocksdb/wiki/Leveled-Compaction // https://github.com/facebook/rocksdb/wiki/Leveled-Compaction
// for description of Leveled compaction. // for description of Leveled compaction.
@ -29,4 +29,4 @@ class LevelCompactionPicker : public CompactionPicker {
const VersionStorageInfo* vstorage) const override; const VersionStorageInfo* vstorage) const override;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -17,7 +17,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CountingLogger : public Logger { class CountingLogger : public Logger {
public: public:
@ -1733,7 +1733,7 @@ TEST_F(CompactionPickerTest, IntraL0ForEarliestSeqno) {
ASSERT_EQ(0, compaction->output_level()); ASSERT_EQ(0, compaction->output_level());
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -23,7 +23,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
// A helper class that form universal compactions. The class is used by // A helper class that form universal compactions. The class is used by
// UniversalCompactionPicker::PickCompaction(). // UniversalCompactionPicker::PickCompaction().
@ -1100,6 +1100,6 @@ Compaction* UniversalCompactionBuilder::PickPeriodicCompaction() {
return c; return c;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -12,7 +12,7 @@
#include "db/compaction/compaction_picker.h" #include "db/compaction/compaction_picker.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class UniversalCompactionPicker : public CompactionPicker { class UniversalCompactionPicker : public CompactionPicker {
public: public:
UniversalCompactionPicker(const ImmutableCFOptions& ioptions, UniversalCompactionPicker(const ImmutableCFOptions& ioptions,
@ -27,5 +27,5 @@ class UniversalCompactionPicker : public CompactionPicker {
virtual bool NeedsCompaction( virtual bool NeedsCompaction(
const VersionStorageInfo* vstorage) const override; const VersionStorageInfo* vstorage) const override;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -18,7 +18,7 @@
using std::unique_ptr; using std::unique_ptr;
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
static const Comparator* kTestComparator = nullptr; static const Comparator* kTestComparator = nullptr;
@ -268,7 +268,7 @@ class ComparatorDBTest
BlockBasedTableOptions toptions; BlockBasedTableOptions toptions;
toptions.format_version = GetParam(); toptions.format_version = GetParam();
last_options_.table_factory.reset( last_options_.table_factory.reset(
rocksdb::NewBlockBasedTableFactory(toptions)); ROCKSDB_NAMESPACE::NewBlockBasedTableFactory(toptions));
EXPECT_OK(DestroyDB(dbname_, last_options_)); EXPECT_OK(DestroyDB(dbname_, last_options_));
} }
@ -652,7 +652,7 @@ TEST_P(ComparatorDBTest, SeparatorSuccessorRandomizeTest) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -11,7 +11,7 @@
#include "db/db_impl/db_impl.h" #include "db/db_impl/db_impl.h"
#include "util/cast_util.h" #include "util/cast_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
void CancelAllBackgroundWork(DB* db, bool wait) { void CancelAllBackgroundWork(DB* db, bool wait) {
(static_cast_with_check<DBImpl, DB>(db->GetRootDB())) (static_cast_with_check<DBImpl, DB>(db->GetRootDB()))
@ -72,6 +72,6 @@ Status VerifySstFileChecksum(const Options& options,
return s; return s;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

View File

@ -33,7 +33,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static const int kValueSize = 1000; static const int kValueSize = 1000;
@ -98,7 +98,7 @@ class CorruptionTest : public testing::Test {
void RepairDB() { void RepairDB() {
delete db_; delete db_;
db_ = nullptr; db_ = nullptr;
ASSERT_OK(::rocksdb::RepairDB(dbname_, options_)); ASSERT_OK(::ROCKSDB_NAMESPACE::RepairDB(dbname_, options_));
} }
void Build(int n, int flush_every = 0) { void Build(int n, int flush_every = 0) {
@ -595,7 +595,7 @@ TEST_F(CorruptionTest, FileSystemStateCorrupted) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -15,7 +15,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class CuckooTableDBTest : public testing::Test { class CuckooTableDBTest : public testing::Test {
private: private:
@ -328,14 +328,13 @@ TEST_F(CuckooTableDBTest, AdaptiveTable) {
ASSERT_EQ("v4", Get("key4")); ASSERT_EQ("v4", Get("key4"));
ASSERT_EQ("v6", Get("key5")); ASSERT_EQ("v6", Get("key5"));
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (rocksdb::port::kLittleEndian) { if (ROCKSDB_NAMESPACE::port::kLittleEndian) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} } else {
else {
fprintf(stderr, "SKIPPED as Cuckoo table doesn't support Big Endian\n"); fprintf(stderr, "SKIPPED as Cuckoo table doesn't support Big Endian\n");
return 0; return 0;
} }

View File

@ -17,7 +17,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#endif #endif
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBBasicTest : public DBTestBase { class DBBasicTest : public DBTestBase {
public: public:
@ -27,8 +27,8 @@ class DBBasicTest : public DBTestBase {
TEST_F(DBBasicTest, OpenWhenOpen) { TEST_F(DBBasicTest, OpenWhenOpen) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.env = env_; options.env = env_;
rocksdb::DB* db2 = nullptr; ROCKSDB_NAMESPACE::DB* db2 = nullptr;
rocksdb::Status s = DB::Open(options, dbname_, &db2); ROCKSDB_NAMESPACE::Status s = DB::Open(options, dbname_, &db2);
ASSERT_EQ(Status::Code::kIOError, s.code()); ASSERT_EQ(Status::Code::kIOError, s.code());
ASSERT_EQ(Status::SubCode::kNone, s.subcode()); ASSERT_EQ(Status::SubCode::kNone, s.subcode());
@ -1048,8 +1048,8 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCF) {
} }
int get_sv_count = 0; int get_sv_count = 0;
rocksdb::DBImpl* db = reinterpret_cast<DBImpl*>(db_); ROCKSDB_NAMESPACE::DBImpl* db = reinterpret_cast<DBImpl*>(db_);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) { "DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) {
if (++get_sv_count == 2) { if (++get_sv_count == 2) {
// After MultiGet refs a couple of CFs, flush all CFs so MultiGet // After MultiGet refs a couple of CFs, flush all CFs so MultiGet
@ -1073,7 +1073,7 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCF) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<int> cfs; std::vector<int> cfs;
std::vector<std::string> keys; std::vector<std::string> keys;
@ -1139,12 +1139,12 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCFMutex) {
int get_sv_count = 0; int get_sv_count = 0;
int retries = 0; int retries = 0;
bool last_try = false; bool last_try = false;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MultiGet::LastTry", [&](void* /*arg*/) { "DBImpl::MultiGet::LastTry", [&](void* /*arg*/) {
last_try = true; last_try = true;
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) { "DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) {
if (last_try) { if (last_try) {
return; return;
@ -1160,7 +1160,7 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCFMutex) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<int> cfs; std::vector<int> cfs;
std::vector<std::string> keys; std::vector<std::string> keys;
@ -1198,8 +1198,8 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCFSnapshot) {
} }
int get_sv_count = 0; int get_sv_count = 0;
rocksdb::DBImpl* db = reinterpret_cast<DBImpl*>(db_); ROCKSDB_NAMESPACE::DBImpl* db = reinterpret_cast<DBImpl*>(db_);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) { "DBImpl::MultiGet::AfterRefSV", [&](void* /*arg*/) {
if (++get_sv_count == 2) { if (++get_sv_count == 2) {
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
@ -1219,7 +1219,7 @@ TEST_P(DBMultiGetTestWithParam, MultiGetMultiCFSnapshot) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<int> cfs; std::vector<int> cfs;
std::vector<std::string> keys; std::vector<std::string> keys;
@ -1558,7 +1558,7 @@ TEST_P(DBMultiGetRowCacheTest, MultiGetBatched) {
do { do {
option_config_ = kRowCache; option_config_ = kRowCache;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
SetPerfLevel(kEnableCount); SetPerfLevel(kEnableCount);
ASSERT_OK(Put(1, "k1", "v1")); ASSERT_OK(Put(1, "k1", "v1"));
@ -1664,13 +1664,13 @@ TEST_F(DBBasicTest, GetAllKeyVersions) {
ASSERT_OK(Delete(std::to_string(i))); ASSERT_OK(Delete(std::to_string(i)));
} }
std::vector<KeyVersion> key_versions; std::vector<KeyVersion> key_versions;
ASSERT_OK(rocksdb::GetAllKeyVersions(db_, Slice(), Slice(), ASSERT_OK(ROCKSDB_NAMESPACE::GetAllKeyVersions(
std::numeric_limits<size_t>::max(), db_, Slice(), Slice(), std::numeric_limits<size_t>::max(),
&key_versions)); &key_versions));
ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates, key_versions.size()); ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates, key_versions.size());
ASSERT_OK(rocksdb::GetAllKeyVersions(db_, handles_[0], Slice(), Slice(), ASSERT_OK(ROCKSDB_NAMESPACE::GetAllKeyVersions(
std::numeric_limits<size_t>::max(), db_, handles_[0], Slice(), Slice(), std::numeric_limits<size_t>::max(),
&key_versions)); &key_versions));
ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates, key_versions.size()); ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates, key_versions.size());
// Check non-default column family // Check non-default column family
@ -1683,9 +1683,9 @@ TEST_F(DBBasicTest, GetAllKeyVersions) {
for (size_t i = 0; i != kNumDeletes - 1; ++i) { for (size_t i = 0; i != kNumDeletes - 1; ++i) {
ASSERT_OK(Delete(1, std::to_string(i))); ASSERT_OK(Delete(1, std::to_string(i)));
} }
ASSERT_OK(rocksdb::GetAllKeyVersions(db_, handles_[1], Slice(), Slice(), ASSERT_OK(ROCKSDB_NAMESPACE::GetAllKeyVersions(
std::numeric_limits<size_t>::max(), db_, handles_[1], Slice(), Slice(), std::numeric_limits<size_t>::max(),
&key_versions)); &key_versions));
ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates - 3, key_versions.size()); ASSERT_EQ(kNumInserts + kNumDeletes + kNumUpdates - 3, key_versions.size());
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
@ -2527,7 +2527,7 @@ TEST_P(DBBasicTestWithTimestampWithParam, PutAndGet) {
INSTANTIATE_TEST_CASE_P(Timestamp, DBBasicTestWithTimestampWithParam, INSTANTIATE_TEST_CASE_P(Timestamp, DBBasicTestWithTimestampWithParam,
::testing::Bool()); ::testing::Bool());
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
extern "C" { extern "C" {
@ -2538,7 +2538,7 @@ void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
#endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
RegisterCustomObjects(argc, argv); RegisterCustomObjects(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -23,7 +23,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// kTypeBlobIndex is a value type used by BlobDB only. The base rocksdb // kTypeBlobIndex is a value type used by BlobDB only. The base rocksdb
// should accept the value type on write, and report not supported value // should accept the value type on write, and report not supported value
@ -427,10 +427,10 @@ TEST_F(DBBlobIndexTest, Iterate) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -12,7 +12,7 @@
#include "port/stack_trace.h" #include "port/stack_trace.h"
#include "util/compression.h" #include "util/compression.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBBlockCacheTest : public DBTestBase { class DBBlockCacheTest : public DBTestBase {
private: private:
@ -46,7 +46,7 @@ class DBBlockCacheTest : public DBTestBase {
options.create_if_missing = true; options.create_if_missing = true;
options.avoid_flush_during_recovery = false; options.avoid_flush_during_recovery = false;
// options.compression = kNoCompression; // options.compression = kNoCompression;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.table_factory.reset(new BlockBasedTableFactory(table_options)); options.table_factory.reset(new BlockBasedTableFactory(table_options));
return options; return options;
} }
@ -292,7 +292,7 @@ TEST_F(DBBlockCacheTest, TestWithCompressedBlockCache) {
TEST_F(DBBlockCacheTest, IndexAndFilterBlocksOfNewTableAddedToCache) { TEST_F(DBBlockCacheTest, IndexAndFilterBlocksOfNewTableAddedToCache) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
table_options.filter_policy.reset(NewBloomFilterPolicy(20)); table_options.filter_policy.reset(NewBloomFilterPolicy(20));
@ -378,7 +378,7 @@ TEST_F(DBBlockCacheTest, FillCacheAndIterateDB) {
TEST_F(DBBlockCacheTest, IndexAndFilterBlocksStats) { TEST_F(DBBlockCacheTest, IndexAndFilterBlocksStats) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
LRUCacheOptions co; LRUCacheOptions co;
@ -464,7 +464,7 @@ TEST_F(DBBlockCacheTest, IndexAndFilterBlocksCachePriority) {
for (auto priority : {Cache::Priority::LOW, Cache::Priority::HIGH}) { for (auto priority : {Cache::Priority::LOW, Cache::Priority::HIGH}) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
table_options.block_cache.reset(new MockCache()); table_options.block_cache.reset(new MockCache());
@ -520,7 +520,7 @@ TEST_F(DBBlockCacheTest, IndexAndFilterBlocksCachePriority) {
TEST_F(DBBlockCacheTest, ParanoidFileChecks) { TEST_F(DBBlockCacheTest, ParanoidFileChecks) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.level0_file_num_compaction_trigger = 2; options.level0_file_num_compaction_trigger = 2;
options.paranoid_file_checks = true; options.paranoid_file_checks = true;
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
@ -576,7 +576,7 @@ TEST_F(DBBlockCacheTest, CompressedCache) {
for (int iter = 0; iter < 4; iter++) { for (int iter = 0; iter < 4; iter++) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_size = 64 * 1024; // small write buffer options.write_buffer_size = 64 * 1024; // small write buffer
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
switch (iter) { switch (iter) {
@ -705,7 +705,7 @@ TEST_F(DBBlockCacheTest, CacheCompressionDict) {
options.compression_opts.max_dict_bytes = 4096; options.compression_opts.max_dict_bytes = 4096;
options.create_if_missing = true; options.create_if_missing = true;
options.num_levels = 2; options.num_levels = 2;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.target_file_size_base = kNumEntriesPerFile * kNumBytesPerEntry; options.target_file_size_base = kNumEntriesPerFile * kNumBytesPerEntry;
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
@ -752,10 +752,10 @@ TEST_F(DBBlockCacheTest, CacheCompressionDict) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -12,7 +12,7 @@
#include "rocksdb/perf_context.h" #include "rocksdb/perf_context.h"
#include "table/block_based/filter_policy_internal.h" #include "table/block_based/filter_policy_internal.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
using BFP = BloomFilterPolicy; using BFP = BloomFilterPolicy;
@ -88,7 +88,7 @@ TEST_P(DBBloomFilterTestDefFormatVersion, KeyMayExist) {
// indexes // indexes
continue; continue;
} }
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
ASSERT_TRUE(!db_->KeyMayExist(ropts, handles_[1], "a", &value)); ASSERT_TRUE(!db_->KeyMayExist(ropts, handles_[1], "a", &value));
@ -150,7 +150,7 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloomCustomPrefixExtractor) {
Options options = last_options_; Options options = last_options_;
options.prefix_extractor = options.prefix_extractor =
std::make_shared<SliceTransformLimitedDomainGeneric>(); std::make_shared<SliceTransformLimitedDomainGeneric>();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
get_perf_context()->EnablePerLevelPerfContext(); get_perf_context()->EnablePerLevelPerfContext();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
bbto.filter_policy.reset(NewBloomFilterPolicy(10, false)); bbto.filter_policy.reset(NewBloomFilterPolicy(10, false));
@ -216,7 +216,7 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloom) {
for (bool partition_filters : {true, false}) { for (bool partition_filters : {true, false}) {
Options options = last_options_; Options options = last_options_;
options.prefix_extractor.reset(NewFixedPrefixTransform(8)); options.prefix_extractor.reset(NewFixedPrefixTransform(8));
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
get_perf_context()->EnablePerLevelPerfContext(); get_perf_context()->EnablePerLevelPerfContext();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
bbto.filter_policy.reset(NewBloomFilterPolicy(10, false)); bbto.filter_policy.reset(NewBloomFilterPolicy(10, false));
@ -267,7 +267,7 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
for (bool partition_filters : {true, false}) { for (bool partition_filters : {true, false}) {
Options options = last_options_; Options options = last_options_;
options.prefix_extractor.reset(NewFixedPrefixTransform(3)); options.prefix_extractor.reset(NewFixedPrefixTransform(3));
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
get_perf_context()->EnablePerLevelPerfContext(); get_perf_context()->EnablePerLevelPerfContext();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
@ -531,7 +531,7 @@ INSTANTIATE_TEST_CASE_P(
TEST_F(DBBloomFilterTest, BloomFilterRate) { TEST_F(DBBloomFilterTest, BloomFilterRate) {
while (ChangeFilterOptions()) { while (ChangeFilterOptions()) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
get_perf_context()->EnablePerLevelPerfContext(); get_perf_context()->EnablePerLevelPerfContext();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -563,7 +563,7 @@ TEST_F(DBBloomFilterTest, BloomFilterRate) {
TEST_F(DBBloomFilterTest, BloomFilterCompatibility) { TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.filter_policy.reset(NewBloomFilterPolicy(10, true)); table_options.filter_policy.reset(NewBloomFilterPolicy(10, true));
options.table_factory.reset(NewBlockBasedTableFactory(table_options)); options.table_factory.reset(NewBlockBasedTableFactory(table_options));
@ -607,7 +607,7 @@ TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
TEST_F(DBBloomFilterTest, BloomFilterReverseCompatibility) { TEST_F(DBBloomFilterTest, BloomFilterReverseCompatibility) {
for (bool partition_filters : {true, false}) { for (bool partition_filters : {true, false}) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
if (partition_filters) { if (partition_filters) {
table_options.partition_filters = true; table_options.partition_filters = true;
@ -654,17 +654,18 @@ class TestingWrappedBlockBasedFilterPolicy : public FilterPolicy {
return "TestingWrappedBlockBasedFilterPolicy"; return "TestingWrappedBlockBasedFilterPolicy";
} }
void CreateFilter(const rocksdb::Slice* keys, int n, void CreateFilter(const ROCKSDB_NAMESPACE::Slice* keys, int n,
std::string* dst) const override { std::string* dst) const override {
std::unique_ptr<rocksdb::Slice[]> user_keys(new rocksdb::Slice[n]); std::unique_ptr<ROCKSDB_NAMESPACE::Slice[]> user_keys(
new ROCKSDB_NAMESPACE::Slice[n]);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
user_keys[i] = convertKey(keys[i]); user_keys[i] = convertKey(keys[i]);
} }
return filter_->CreateFilter(user_keys.get(), n, dst); return filter_->CreateFilter(user_keys.get(), n, dst);
} }
bool KeyMayMatch(const rocksdb::Slice& key, bool KeyMayMatch(const ROCKSDB_NAMESPACE::Slice& key,
const rocksdb::Slice& filter) const override { const ROCKSDB_NAMESPACE::Slice& filter) const override {
counter_++; counter_++;
return filter_->KeyMayMatch(convertKey(key), filter); return filter_->KeyMayMatch(convertKey(key), filter);
} }
@ -675,13 +676,16 @@ class TestingWrappedBlockBasedFilterPolicy : public FilterPolicy {
const FilterPolicy* filter_; const FilterPolicy* filter_;
mutable uint32_t counter_; mutable uint32_t counter_;
rocksdb::Slice convertKey(const rocksdb::Slice& key) const { return key; } ROCKSDB_NAMESPACE::Slice convertKey(
const ROCKSDB_NAMESPACE::Slice& key) const {
return key;
}
}; };
} // namespace } // namespace
TEST_F(DBBloomFilterTest, WrappedBlockBasedFilterPolicy) { TEST_F(DBBloomFilterTest, WrappedBlockBasedFilterPolicy) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
TestingWrappedBlockBasedFilterPolicy* policy = TestingWrappedBlockBasedFilterPolicy* policy =
@ -797,7 +801,7 @@ class TestingContextCustomFilterPolicy
TEST_F(DBBloomFilterTest, ContextCustomFilterPolicy) { TEST_F(DBBloomFilterTest, ContextCustomFilterPolicy) {
for (bool fifo : {true, false}) { for (bool fifo : {true, false}) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.compaction_style = options.compaction_style =
fifo ? kCompactionStyleFIFO : kCompactionStyleLevel; fifo ? kCompactionStyleFIFO : kCompactionStyleLevel;
@ -896,7 +900,7 @@ class SliceTransformLimitedDomain : public SliceTransform {
TEST_F(DBBloomFilterTest, PrefixExtractorFullFilter) { TEST_F(DBBloomFilterTest, PrefixExtractorFullFilter) {
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
// Full Filter Block // Full Filter Block
bbto.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, false)); bbto.filter_policy.reset(ROCKSDB_NAMESPACE::NewBloomFilterPolicy(10, false));
bbto.whole_key_filtering = false; bbto.whole_key_filtering = false;
Options options = CurrentOptions(); Options options = CurrentOptions();
@ -925,7 +929,7 @@ TEST_F(DBBloomFilterTest, PrefixExtractorFullFilter) {
TEST_F(DBBloomFilterTest, PrefixExtractorBlockFilter) { TEST_F(DBBloomFilterTest, PrefixExtractorBlockFilter) {
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
// Block Filter Block // Block Filter Block
bbto.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, true)); bbto.filter_policy.reset(ROCKSDB_NAMESPACE::NewBloomFilterPolicy(10, true));
Options options = CurrentOptions(); Options options = CurrentOptions();
options.prefix_extractor = std::make_shared<SliceTransformLimitedDomain>(); options.prefix_extractor = std::make_shared<SliceTransformLimitedDomain>();
@ -964,7 +968,8 @@ TEST_F(DBBloomFilterTest, MemtableWholeKeyBloomFilter) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.memtable_prefix_bloom_size_ratio = options.memtable_prefix_bloom_size_ratio =
static_cast<double>(kMemtablePrefixFilterSize) / kMemtableSize; static_cast<double>(kMemtablePrefixFilterSize) / kMemtableSize;
options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(kPrefixLen)); options.prefix_extractor.reset(
ROCKSDB_NAMESPACE::NewFixedPrefixTransform(kPrefixLen));
options.write_buffer_size = kMemtableSize; options.write_buffer_size = kMemtableSize;
options.memtable_whole_key_filtering = false; options.memtable_whole_key_filtering = false;
Reopen(options); Reopen(options);
@ -1042,7 +1047,8 @@ class BloomStatsTestWithParam
partition_filters_ = std::get<1>(GetParam()); partition_filters_ = std::get<1>(GetParam());
options_.create_if_missing = true; options_.create_if_missing = true;
options_.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(4)); options_.prefix_extractor.reset(
ROCKSDB_NAMESPACE::NewFixedPrefixTransform(4));
options_.memtable_prefix_bloom_size_ratio = options_.memtable_prefix_bloom_size_ratio =
8.0 * 1024.0 / static_cast<double>(options_.write_buffer_size); 8.0 * 1024.0 / static_cast<double>(options_.write_buffer_size);
if (bfp_impl_ == BFP2::kPlainTable) { if (bfp_impl_ == BFP2::kPlainTable) {
@ -1323,7 +1329,7 @@ TEST_F(DBBloomFilterTest, OptimizeFiltersForHits) {
bbto.whole_key_filtering = true; bbto.whole_key_filtering = true;
options.table_factory.reset(NewBlockBasedTableFactory(bbto)); options.table_factory.reset(NewBlockBasedTableFactory(bbto));
options.optimize_filters_for_hits = true; options.optimize_filters_for_hits = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
get_perf_context()->Reset(); get_perf_context()->Reset();
get_perf_context()->EnablePerLevelPerfContext(); get_perf_context()->EnablePerLevelPerfContext();
CreateAndReopenWithCF({"mypikachu"}, options); CreateAndReopenWithCF({"mypikachu"}, options);
@ -1449,13 +1455,13 @@ TEST_F(DBBloomFilterTest, OptimizeFiltersForHits) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.bottommost_level_compaction = compact_options.bottommost_level_compaction =
@ -1895,10 +1901,10 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterOptions) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -10,7 +10,7 @@
#include "db/db_test_util.h" #include "db/db_test_util.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static int cfilter_count = 0; static int cfilter_count = 0;
static int cfilter_skips = 0; static int cfilter_skips = 0;
@ -863,10 +863,10 @@ TEST_F(DBTestCompactionFilter, IgnoreSnapshotsFalse) {
delete options.compaction_filter; delete options.compaction_filter;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -18,7 +18,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/concurrent_task_limiter_impl.h" #include "util/concurrent_task_limiter_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// SYNC_POINT is not supported in released Windows mode. // SYNC_POINT is not supported in released Windows mode.
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
@ -417,7 +417,7 @@ TEST_F(DBCompactionTest, SkipStatsUpdateTest) {
Close(); Close();
int update_acc_stats_called = 0; int update_acc_stats_called = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"VersionStorageInfo::UpdateAccumulatedStats", "VersionStorageInfo::UpdateAccumulatedStats",
[&](void* /* arg */) { ++update_acc_stats_called; }); [&](void* /* arg */) { ++update_acc_stats_called; });
SyncPoint::GetInstance()->EnableProcessing(); SyncPoint::GetInstance()->EnableProcessing();
@ -451,7 +451,7 @@ TEST_F(DBCompactionTest, TestTableReaderForCompaction) {
int num_table_cache_lookup = 0; int num_table_cache_lookup = 0;
int num_new_table_reader = 0; int num_new_table_reader = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"TableCache::FindTable:0", [&](void* arg) { "TableCache::FindTable:0", [&](void* arg) {
assert(arg != nullptr); assert(arg != nullptr);
bool no_io = *(reinterpret_cast<bool*>(arg)); bool no_io = *(reinterpret_cast<bool*>(arg));
@ -460,10 +460,10 @@ TEST_F(DBCompactionTest, TestTableReaderForCompaction) {
num_table_cache_lookup++; num_table_cache_lookup++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"TableCache::GetTableReader:0", "TableCache::GetTableReader:0",
[&](void* /*arg*/) { num_new_table_reader++; }); [&](void* /*arg*/) { num_new_table_reader++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int k = 0; k < options.level0_file_num_compaction_trigger; ++k) { for (int k = 0; k < options.level0_file_num_compaction_trigger; ++k) {
ASSERT_OK(Put(Key(k), Key(k))); ASSERT_OK(Put(Key(k), Key(k)));
@ -533,7 +533,7 @@ TEST_F(DBCompactionTest, TestTableReaderForCompaction) {
ASSERT_EQ(num_table_cache_lookup + old_num_table_cache_lookup2, 3); ASSERT_EQ(num_table_cache_lookup + old_num_table_cache_lookup2, 3);
ASSERT_EQ(num_new_table_reader, 0); ASSERT_EQ(num_new_table_reader, 0);
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_P(DBCompactionTestWithParam, CompactionDeletionTriggerReopen) { TEST_P(DBCompactionTestWithParam, CompactionDeletionTriggerReopen) {
@ -1023,10 +1023,10 @@ TEST_F(DBCompactionTest, RecoverDuringMemtableCompaction) {
TEST_P(DBCompactionTestWithParam, TrivialMoveOneFile) { TEST_P(DBCompactionTestWithParam, TrivialMoveOneFile) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_size = 100000000; options.write_buffer_size = 100000000;
@ -1074,19 +1074,19 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveOneFile) {
} }
ASSERT_EQ(trivial_move, 1); ASSERT_EQ(trivial_move, 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) { TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
@ -1173,19 +1173,19 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) {
ASSERT_EQ(trivial_move, 0); ASSERT_EQ(trivial_move, 0);
ASSERT_EQ(non_trivial_move, 1); ASSERT_EQ(non_trivial_move, 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBCompactionTestWithParam, TrivialMoveTargetLevel) { TEST_P(DBCompactionTestWithParam, TrivialMoveTargetLevel) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
@ -1238,10 +1238,10 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveTargetLevel) {
TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) { TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
bool first = true; bool first = true;
@ -1249,11 +1249,11 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
// 4 -> 1: ensure the order of two non-trivial compactions // 4 -> 1: ensure the order of two non-trivial compactions
// 5 -> 2 and 5 -> 3: ensure we do a check before two non-trivial compactions // 5 -> 2 and 5 -> 3: ensure we do a check before two non-trivial compactions
// are installed // are installed
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBCompaction::ManualPartial:4", "DBCompaction::ManualPartial:1"}, {{"DBCompaction::ManualPartial:4", "DBCompaction::ManualPartial:1"},
{"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:2"}, {"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:2"},
{"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:3"}}); {"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (first) { if (first) {
first = false; first = false;
@ -1264,7 +1264,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_size = 10 * 1024 * 1024; options.write_buffer_size = 10 * 1024 * 1024;
@ -1329,7 +1329,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
ASSERT_EQ(trivial_move, 6); ASSERT_EQ(trivial_move, 6);
ASSERT_EQ(non_trivial_move, 0); ASSERT_EQ(non_trivial_move, 0);
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
compact_options.change_level = false; compact_options.change_level = false;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
std::string begin_string = Key(0); std::string begin_string = Key(0);
@ -1383,18 +1383,18 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) { TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
bool first = true; bool first = true;
bool second = true; bool second = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBCompaction::PartialFill:4", "DBCompaction::PartialFill:1"}, {{"DBCompaction::PartialFill:4", "DBCompaction::PartialFill:1"},
{"DBCompaction::PartialFill:2", "DBCompaction::PartialFill:3"}}); {"DBCompaction::PartialFill:2", "DBCompaction::PartialFill:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (first) { if (first) {
TEST_SYNC_POINT("DBCompaction::PartialFill:4"); TEST_SYNC_POINT("DBCompaction::PartialFill:4");
@ -1404,7 +1404,7 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_size = 10 * 1024 * 1024; options.write_buffer_size = 10 * 1024 * 1024;
@ -1465,7 +1465,7 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
ASSERT_EQ(trivial_move, 2); ASSERT_EQ(trivial_move, 2);
ASSERT_EQ(non_trivial_move, 0); ASSERT_EQ(non_trivial_move, 0);
rocksdb::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
compact_options.change_level = false; compact_options.change_level = false;
compact_options.exclusive_manual_compaction = false; compact_options.exclusive_manual_compaction = false;
std::string begin_string = Key(0); std::string begin_string = Key(0);
@ -1507,7 +1507,7 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
} }
TEST_F(DBCompactionTest, ManualCompactionWithUnorderedWrite) { TEST_F(DBCompactionTest, ManualCompactionWithUnorderedWrite) {
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WriteImpl:UnorderedWriteAfterWriteWAL", {{"DBImpl::WriteImpl:UnorderedWriteAfterWriteWAL",
"DBCompactionTest::ManualCompactionWithUnorderedWrite:WaitWriteWAL"}, "DBCompactionTest::ManualCompactionWithUnorderedWrite:WaitWriteWAL"},
{"DBImpl::WaitForPendingWrites:BeforeBlock", {"DBImpl::WaitForPendingWrites:BeforeBlock",
@ -1520,7 +1520,7 @@ TEST_F(DBCompactionTest, ManualCompactionWithUnorderedWrite) {
ASSERT_OK(Flush()); ASSERT_OK(Flush());
Put("bar", "v1"); Put("bar", "v1");
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
port::Thread writer([&]() { Put("foo", "v2"); }); port::Thread writer([&]() { Put("foo", "v2"); });
TEST_SYNC_POINT( TEST_SYNC_POINT(
@ -1831,13 +1831,13 @@ TEST_F(DBCompactionTest, DeleteFileRangeFileEndpointsOverlapBug) {
TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) { TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_size = 100000000; options.write_buffer_size = 100000000;
@ -1886,7 +1886,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) {
ASSERT_EQ(Get(Key(i)), values[i]); ASSERT_EQ(Get(Key(i)), values[i]);
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBCompactionTestWithParam, LevelCompactionThirdPath) { TEST_P(DBCompactionTestWithParam, LevelCompactionThirdPath) {
@ -2399,12 +2399,12 @@ TEST_F(DBCompactionTest, L0_CompactionBug_Issue44_b) {
TEST_F(DBCompactionTest, ManualAutoRace) { TEST_F(DBCompactionTest, ManualAutoRace) {
CreateAndReopenWithCF({"pikachu"}, CurrentOptions()); CreateAndReopenWithCF({"pikachu"}, CurrentOptions());
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::BGWorkCompaction", "DBCompactionTest::ManualAutoRace:1"}, {{"DBImpl::BGWorkCompaction", "DBCompactionTest::ManualAutoRace:1"},
{"DBImpl::RunManualCompaction:WaitScheduled", {"DBImpl::RunManualCompaction:WaitScheduled",
"BackgroundCallCompaction:0"}}); "BackgroundCallCompaction:0"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put(1, "foo", ""); Put(1, "foo", "");
Put(1, "bar", ""); Put(1, "bar", "");
@ -2435,13 +2435,13 @@ TEST_F(DBCompactionTest, ManualAutoRace) {
// Eventually the cancelled compaction will be rescheduled and executed. // Eventually the cancelled compaction will be rescheduled and executed.
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
ASSERT_EQ("0,1", FilesPerLevel(0)); ASSERT_EQ("0,1", FilesPerLevel(0));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBCompactionTestWithParam, ManualCompaction) { TEST_P(DBCompactionTestWithParam, ManualCompaction) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_subcompactions = max_subcompactions_; options.max_subcompactions = max_subcompactions_;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
// iter - 0 with 7 levels // iter - 0 with 7 levels
@ -2489,7 +2489,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompaction) {
options = CurrentOptions(); options = CurrentOptions();
options.num_levels = 3; options.num_levels = 3;
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
} }
@ -2836,19 +2836,19 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) {
kZlibCompression}; kZlibCompression};
int matches = 0, didnt_match = 0, trivial_move = 0, non_trivial = 0; int matches = 0, didnt_match = 0, trivial_move = 0, non_trivial = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Compaction::InputCompressionMatchesOutput:Matches", "Compaction::InputCompressionMatchesOutput:Matches",
[&](void* /*arg*/) { matches++; }); [&](void* /*arg*/) { matches++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Compaction::InputCompressionMatchesOutput:DidntMatch", "Compaction::InputCompressionMatchesOutput:DidntMatch",
[&](void* /*arg*/) { didnt_match++; }); [&](void* /*arg*/) { didnt_match++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial++; }); [&](void* /*arg*/) { non_trivial++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Reopen(options); Reopen(options);
@ -2909,7 +2909,7 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) {
ASSERT_EQ(trivial_move, 12); ASSERT_EQ(trivial_move, 12);
ASSERT_EQ(non_trivial, 8); ASSERT_EQ(non_trivial, 8);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
for (int i = 0; i < key_idx; i++) { for (int i = 0; i < key_idx; i++) {
auto v = Get(Key(i)); auto v = Get(Key(i));
@ -2971,13 +2971,13 @@ TEST_F(DBCompactionTest, SuggestCompactRangeNoTwoLevel0Compactions) {
} }
db_->CompactRange(CompactRangeOptions(), nullptr, nullptr); db_->CompactRange(CompactRangeOptions(), nullptr, nullptr);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"CompactionJob::Run():Start", {{"CompactionJob::Run():Start",
"DBCompactionTest::SuggestCompactRangeNoTwoLevel0Compactions:1"}, "DBCompactionTest::SuggestCompactRangeNoTwoLevel0Compactions:1"},
{"DBCompactionTest::SuggestCompactRangeNoTwoLevel0Compactions:2", {"DBCompactionTest::SuggestCompactRangeNoTwoLevel0Compactions:2",
"CompactionJob::Run():End"}}); "CompactionJob::Run():End"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// trigger L0 compaction // trigger L0 compaction
for (int num = 0; num < options.level0_file_num_compaction_trigger + 1; for (int num = 0; num < options.level0_file_num_compaction_trigger + 1;
@ -3013,25 +3013,26 @@ static std::string ShortKey(int i) {
TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) { TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial_move++; }); [&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// The key size is guaranteed to be <= 8 // The key size is guaranteed to be <= 8
class ShortKeyComparator : public Comparator { class ShortKeyComparator : public Comparator {
int Compare(const rocksdb::Slice& a, int Compare(const ROCKSDB_NAMESPACE::Slice& a,
const rocksdb::Slice& b) const override { const ROCKSDB_NAMESPACE::Slice& b) const override {
assert(a.size() <= 8); assert(a.size() <= 8);
assert(b.size() <= 8); assert(b.size() <= 8);
return BytewiseComparator()->Compare(a, b); return BytewiseComparator()->Compare(a, b);
} }
const char* Name() const override { return "ShortKeyComparator"; } const char* Name() const override { return "ShortKeyComparator"; }
void FindShortestSeparator(std::string* start, void FindShortestSeparator(
const rocksdb::Slice& limit) const override { std::string* start,
const ROCKSDB_NAMESPACE::Slice& limit) const override {
return BytewiseComparator()->FindShortestSeparator(start, limit); return BytewiseComparator()->FindShortestSeparator(start, limit);
} }
void FindShortSuccessor(std::string* key) const override { void FindShortSuccessor(std::string* key) const override {
@ -3108,7 +3109,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
ASSERT_EQ(Get(ShortKey(i)), values[i]); ASSERT_EQ(Get(ShortKey(i)), values[i]);
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBCompactionTestWithParam, IntraL0Compaction) { TEST_P(DBCompactionTestWithParam, IntraL0Compaction) {
@ -3123,10 +3124,10 @@ TEST_P(DBCompactionTestWithParam, IntraL0Compaction) {
Random rnd(301); Random rnd(301);
std::string value(RandomString(&rnd, kValueSize)); std::string value(RandomString(&rnd, kValueSize));
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"LevelCompactionPicker::PickCompactionBySize:0", {{"LevelCompactionPicker::PickCompactionBySize:0",
"CompactionJob::Run():Start"}}); "CompactionJob::Run():Start"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// index: 0 1 2 3 4 5 6 7 8 9 // index: 0 1 2 3 4 5 6 7 8 9
// size: 1MB 1MB 1MB 1MB 1MB 2MB 1MB 1MB 1MB 1MB // size: 1MB 1MB 1MB 1MB 1MB 2MB 1MB 1MB 1MB 1MB
@ -3149,7 +3150,7 @@ TEST_P(DBCompactionTestWithParam, IntraL0Compaction) {
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
std::vector<std::vector<FileMetaData>> level_to_files; std::vector<std::vector<FileMetaData>> level_to_files;
dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(), dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(),
@ -3177,10 +3178,10 @@ TEST_P(DBCompactionTestWithParam, IntraL0CompactionDoesNotObsoleteDeletions) {
Random rnd(301); Random rnd(301);
std::string value(RandomString(&rnd, kValueSize)); std::string value(RandomString(&rnd, kValueSize));
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"LevelCompactionPicker::PickCompactionBySize:0", {{"LevelCompactionPicker::PickCompactionBySize:0",
"CompactionJob::Run():Start"}}); "CompactionJob::Run():Start"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// index: 0 1 2 3 4 5 6 7 8 9 // index: 0 1 2 3 4 5 6 7 8 9
// size: 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB // size: 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB 1MB
@ -3206,7 +3207,7 @@ TEST_P(DBCompactionTestWithParam, IntraL0CompactionDoesNotObsoleteDeletions) {
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
std::vector<std::vector<FileMetaData>> level_to_files; std::vector<std::vector<FileMetaData>> level_to_files;
dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(), dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(),
@ -3259,7 +3260,7 @@ TEST_P(DBCompactionTestWithParam, FullCompactionInBottomPriThreadPool) {
// Verify that size amplification did occur // Verify that size amplification did occur
ASSERT_EQ(NumSortedRuns(), 1); ASSERT_EQ(NumSortedRuns(), 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
Env::Default()->SetBackgroundThreads(0, Env::Priority::BOTTOM); Env::Default()->SetBackgroundThreads(0, Env::Priority::BOTTOM);
} }
@ -3270,7 +3271,7 @@ TEST_F(DBCompactionTest, OptimizedDeletionObsoleting) {
const int kNumL0Files = 4; const int kNumL0Files = 4;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.level0_file_num_compaction_trigger = kNumL0Files; options.level0_file_num_compaction_trigger = kNumL0Files;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
// put key 1 and 3 in separate L1, L2 files. // put key 1 and 3 in separate L1, L2 files.
@ -3315,12 +3316,12 @@ TEST_F(DBCompactionTest, CompactFilesPendingL0Bug) {
options.max_background_compactions = 2; options.max_background_compactions = 2;
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"LevelCompactionPicker::PickCompaction:Return", {{"LevelCompactionPicker::PickCompaction:Return",
"DBCompactionTest::CompactFilesPendingL0Bug:Picked"}, "DBCompactionTest::CompactFilesPendingL0Bug:Picked"},
{"DBCompactionTest::CompactFilesPendingL0Bug:ManualCompacted", {"DBCompactionTest::CompactFilesPendingL0Bug:ManualCompacted",
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun"}}); "DBImpl::BackgroundCompaction:NonTrivial:AfterRun"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
auto schedule_multi_compaction_token = auto schedule_multi_compaction_token =
dbfull()->TEST_write_controler().GetCompactionPressureToken(); dbfull()->TEST_write_controler().GetCompactionPressureToken();
@ -3350,7 +3351,7 @@ TEST_F(DBCompactionTest, CompactFilesPendingL0Bug) {
->CompactFiles(CompactionOptions(), input_filenames, ->CompactFiles(CompactionOptions(), input_filenames,
0 /* output_level */)); 0 /* output_level */));
TEST_SYNC_POINT("DBCompactionTest::CompactFilesPendingL0Bug:ManualCompacted"); TEST_SYNC_POINT("DBCompactionTest::CompactFilesPendingL0Bug:ManualCompacted");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, CompactFilesOverlapInL0Bug) { TEST_F(DBCompactionTest, CompactFilesOverlapInL0Bug) {
@ -3424,13 +3425,13 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) {
// file without changing file count. // file without changing file count.
db_->ReleaseSnapshot(snapshot); db_->ReleaseSnapshot(snapshot);
ASSERT_EQ(kMaxSequenceNumber, dbfull()->bottommost_files_mark_threshold_); ASSERT_EQ(kMaxSequenceNumber, dbfull()->bottommost_files_mark_threshold_);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
ASSERT_TRUE(compaction->compaction_reason() == ASSERT_TRUE(compaction->compaction_reason() ==
CompactionReason::kBottommostFiles); CompactionReason::kBottommostFiles);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
db_->GetLiveFilesMetaData(&post_release_metadata); db_->GetLiveFilesMetaData(&post_release_metadata);
ASSERT_EQ(pre_release_metadata.size(), post_release_metadata.size()); ASSERT_EQ(pre_release_metadata.size(), post_release_metadata.size());
@ -3444,7 +3445,7 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) {
// deletion markers/deleted keys. // deletion markers/deleted keys.
ASSERT_LT(post_file.size, pre_file.size); ASSERT_LT(post_file.size, pre_file.size);
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) { TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
@ -3493,16 +3494,16 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
// compacted. // compacted.
ASSERT_OK(Put("a", "1")); ASSERT_OK(Put("a", "1"));
Flush(); Flush();
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
ASSERT_TRUE(compaction->compaction_reason() == CompactionReason::kTtl); ASSERT_TRUE(compaction->compaction_reason() == CompactionReason::kTtl);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
// All non-L0 files are deleted, as they contained only deleted data. // All non-L0 files are deleted, as they contained only deleted data.
ASSERT_EQ("1", FilesPerLevel()); ASSERT_EQ("1", FilesPerLevel());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
// Test dynamically changing ttl. // Test dynamically changing ttl.
@ -3540,12 +3541,12 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
ASSERT_EQ("1,2,0,2", FilesPerLevel()); ASSERT_EQ("1,2,0,2", FilesPerLevel());
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
ASSERT_TRUE(compaction->compaction_reason() == CompactionReason::kTtl); ASSERT_TRUE(compaction->compaction_reason() == CompactionReason::kTtl);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Dynamically change ttl to 10 hours. // Dynamically change ttl to 10 hours.
// This should trigger a ttl compaction, as 12 hours have already passed. // This should trigger a ttl compaction, as 12 hours have already passed.
@ -3553,7 +3554,7 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
// All non-L0 files are deleted, as they contained only deleted data. // All non-L0 files are deleted, as they contained only deleted data.
ASSERT_EQ("1", FilesPerLevel()); ASSERT_EQ("1", FilesPerLevel());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) { TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
@ -3570,7 +3571,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
options.max_open_files = 20; options.max_open_files = 20;
} }
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = 2; *max_open_files = 2;
@ -3578,7 +3579,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
// In the case where all files are opened and doing DB restart // In the case where all files are opened and doing DB restart
// forcing the oldest ancester time in manifest file to be 0 to // forcing the oldest ancester time in manifest file to be 0 to
// simulate the case of reading from an old version. // simulate the case of reading from an old version.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"VersionEdit::EncodeTo:VarintOldestAncesterTime", [&](void* arg) { "VersionEdit::EncodeTo:VarintOldestAncesterTime", [&](void* arg) {
if (if_restart && if_open_all_files) { if (if_restart && if_open_all_files) {
std::string* encoded_fieled = static_cast<std::string*>(arg); std::string* encoded_fieled = static_cast<std::string*>(arg);
@ -3594,7 +3595,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
DestroyAndReopen(options); DestroyAndReopen(options);
int ttl_compactions = 0; int ttl_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
auto compaction_reason = compaction->compaction_reason(); auto compaction_reason = compaction->compaction_reason();
@ -3602,7 +3603,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
ttl_compactions++; ttl_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Add two L6 files with key ranges: [1 .. 100], [101 .. 200]. // Add two L6 files with key ranges: [1 .. 100], [101 .. 200].
Random rnd(301); Random rnd(301);
@ -3697,7 +3698,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
ASSERT_EQ("1,0,0,0,0,0,1", FilesPerLevel()); ASSERT_EQ("1,0,0,0,0,0,1", FilesPerLevel());
ASSERT_GE(ttl_compactions, 6); ASSERT_GE(ttl_compactions, 6);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
} }
@ -3717,7 +3718,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
options.max_open_files = 20; options.max_open_files = 20;
} }
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = 0; *max_open_files = 0;
@ -3725,7 +3726,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
// In the case where all files are opened and doing DB restart // In the case where all files are opened and doing DB restart
// forcing the file creation time in manifest file to be 0 to // forcing the file creation time in manifest file to be 0 to
// simulate the case of reading from an old version. // simulate the case of reading from an old version.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"VersionEdit::EncodeTo:VarintFileCreationTime", [&](void* arg) { "VersionEdit::EncodeTo:VarintFileCreationTime", [&](void* arg) {
if (if_restart && if_open_all_files) { if (if_restart && if_open_all_files) {
std::string* encoded_fieled = static_cast<std::string*>(arg); std::string* encoded_fieled = static_cast<std::string*>(arg);
@ -3741,7 +3742,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
DestroyAndReopen(options); DestroyAndReopen(options);
int periodic_compactions = 0; int periodic_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
auto compaction_reason = compaction->compaction_reason(); auto compaction_reason = compaction->compaction_reason();
@ -3749,7 +3750,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
periodic_compactions++; periodic_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int i = 0; i < kNumLevelFiles; ++i) { for (int i = 0; i < kNumLevelFiles; ++i) {
@ -3801,7 +3802,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
// + 4. // + 4.
ASSERT_EQ(9, periodic_compactions); ASSERT_EQ(9, periodic_compactions);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
} }
@ -3825,7 +3826,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithOldDB) {
int periodic_compactions = 0; int periodic_compactions = 0;
bool set_file_creation_time_to_zero = true; bool set_file_creation_time_to_zero = true;
bool set_creation_time_to_zero = true; bool set_creation_time_to_zero = true;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
auto compaction_reason = compaction->compaction_reason(); auto compaction_reason = compaction->compaction_reason();
@ -3833,7 +3834,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithOldDB) {
periodic_compactions++; periodic_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"PropertyBlockBuilder::AddTableProperty:Start", [&](void* arg) { "PropertyBlockBuilder::AddTableProperty:Start", [&](void* arg) {
TableProperties* props = reinterpret_cast<TableProperties*>(arg); TableProperties* props = reinterpret_cast<TableProperties*>(arg);
if (set_file_creation_time_to_zero) { if (set_file_creation_time_to_zero) {
@ -3843,7 +3844,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithOldDB) {
props->creation_time = 0; props->creation_time = 0;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int i = 0; i < kNumFiles; ++i) { for (int i = 0; i < kNumFiles; ++i) {
@ -3876,7 +3877,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithOldDB) {
// Make sure that all files go through periodic compaction. // Make sure that all files go through periodic compaction.
ASSERT_EQ(kNumFiles, periodic_compactions); ASSERT_EQ(kNumFiles, periodic_compactions);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) { TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) {
@ -3896,7 +3897,7 @@ TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) {
int periodic_compactions = 0; int periodic_compactions = 0;
int ttl_compactions = 0; int ttl_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
auto compaction_reason = compaction->compaction_reason(); auto compaction_reason = compaction->compaction_reason();
@ -3906,7 +3907,7 @@ TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) {
ttl_compactions++; ttl_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int i = 0; i < kNumLevelFiles; ++i) { for (int i = 0; i < kNumLevelFiles; ++i) {
@ -3957,7 +3958,7 @@ TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) {
ASSERT_EQ(6, periodic_compactions); ASSERT_EQ(6, periodic_compactions);
ASSERT_EQ(6, ttl_compactions); ASSERT_EQ(6, ttl_compactions);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) { TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) {
@ -4010,7 +4011,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) {
dbfull()->GetOptions().periodic_compaction_seconds); dbfull()->GetOptions().periodic_compaction_seconds);
int periodic_compactions = 0; int periodic_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
auto compaction_reason = compaction->compaction_reason(); auto compaction_reason = compaction->compaction_reason();
@ -4018,7 +4019,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) {
periodic_compactions++; periodic_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int i = 0; i < kNumLevelFiles; ++i) { for (int i = 0; i < kNumLevelFiles; ++i) {
for (int j = 0; j < kNumKeysPerFile; ++j) { for (int j = 0; j < kNumKeysPerFile; ++j) {
@ -4042,7 +4043,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) {
// The two old files go through the periodic compaction process // The two old files go through the periodic compaction process
ASSERT_EQ(2, periodic_compactions); ASSERT_EQ(2, periodic_compactions);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -4068,16 +4069,17 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByL0FileCount) {
if (i == 0) { if (i == 0) {
// ensure the auto compaction doesn't finish until manual compaction has // ensure the auto compaction doesn't finish until manual compaction has
// had a chance to be delayed. // had a chance to be delayed.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait", {{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait",
"CompactionJob::Run():End"}}); "CompactionJob::Run():End"}});
} else { } else {
// ensure the auto-compaction doesn't finish until manual compaction has // ensure the auto-compaction doesn't finish until manual compaction has
// continued without delay. // continued without delay.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::FlushMemTable:StallWaitDone", "CompactionJob::Run():End"}}); {{"DBImpl::FlushMemTable:StallWaitDone",
"CompactionJob::Run():End"}});
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int j = 0; j < kNumL0FilesLimit - 1; ++j) { for (int j = 0; j < kNumL0FilesLimit - 1; ++j) {
@ -4096,7 +4098,7 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByL0FileCount) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
ASSERT_EQ(0, NumTableFilesAtLevel(0)); ASSERT_EQ(0, NumTableFilesAtLevel(0));
ASSERT_GT(NumTableFilesAtLevel(1), 0); ASSERT_GT(NumTableFilesAtLevel(1), 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -4122,17 +4124,17 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByImmMemTableCount) {
if (i == 0) { if (i == 0) {
// ensure the flush doesn't finish until manual compaction has had a // ensure the flush doesn't finish until manual compaction has had a
// chance to be delayed. // chance to be delayed.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait", {{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait",
"FlushJob::WriteLevel0Table"}}); "FlushJob::WriteLevel0Table"}});
} else { } else {
// ensure the flush doesn't finish until manual compaction has continued // ensure the flush doesn't finish until manual compaction has continued
// without delay. // without delay.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::FlushMemTable:StallWaitDone", {{"DBImpl::FlushMemTable:StallWaitDone",
"FlushJob::WriteLevel0Table"}}); "FlushJob::WriteLevel0Table"}});
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int j = 0; j < kNumImmMemTableLimit - 1; ++j) { for (int j = 0; j < kNumImmMemTableLimit - 1; ++j) {
@ -4153,7 +4155,7 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByImmMemTableCount) {
dbfull()->TEST_WaitForFlushMemTable(); dbfull()->TEST_WaitForFlushMemTable();
ASSERT_EQ(0, NumTableFilesAtLevel(0)); ASSERT_EQ(0, NumTableFilesAtLevel(0));
ASSERT_GT(NumTableFilesAtLevel(1), 0); ASSERT_GT(NumTableFilesAtLevel(1), 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -4174,12 +4176,12 @@ TEST_F(DBCompactionTest, CompactRangeShutdownWhileDelayed) {
// The calls to close CF/DB wait until the manual compaction stalls. // The calls to close CF/DB wait until the manual compaction stalls.
// The auto-compaction waits until the manual compaction finishes to ensure // The auto-compaction waits until the manual compaction finishes to ensure
// the signal comes from closing CF/DB, not from compaction making progress. // the signal comes from closing CF/DB, not from compaction making progress.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait", {{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait",
"DBCompactionTest::CompactRangeShutdownWhileDelayed:PreShutdown"}, "DBCompactionTest::CompactRangeShutdownWhileDelayed:PreShutdown"},
{"DBCompactionTest::CompactRangeShutdownWhileDelayed:PostManual", {"DBCompactionTest::CompactRangeShutdownWhileDelayed:PostManual",
"CompactionJob::Run():End"}}); "CompactionJob::Run():End"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int j = 0; j < kNumL0FilesLimit - 1; ++j) { for (int j = 0; j < kNumL0FilesLimit - 1; ++j) {
@ -4212,7 +4214,7 @@ TEST_F(DBCompactionTest, CompactRangeShutdownWhileDelayed) {
TEST_SYNC_POINT( TEST_SYNC_POINT(
"DBCompactionTest::CompactRangeShutdownWhileDelayed:PostManual"); "DBCompactionTest::CompactRangeShutdownWhileDelayed:PostManual");
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -4231,13 +4233,13 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
// The manual flush includes the memtable that was active when CompactRange // The manual flush includes the memtable that was active when CompactRange
// began. So it unblocks CompactRange and precludes its flush. Throughout the // began. So it unblocks CompactRange and precludes its flush. Throughout the
// test, stall conditions are upheld via high L0 file count. // test, stall conditions are upheld via high L0 file count.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait", {{"DBImpl::WaitUntilFlushWouldNotStallWrites:StallWait",
"DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush"}, "DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush"},
{"DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush", {"DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush",
"DBImpl::FlushMemTable:StallWaitDone"}, "DBImpl::FlushMemTable:StallWaitDone"},
{"DBImpl::FlushMemTable:StallWaitDone", "CompactionJob::Run():End"}}); {"DBImpl::FlushMemTable:StallWaitDone", "CompactionJob::Run():End"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
//used for the delayable flushes //used for the delayable flushes
FlushOptions flush_opts; FlushOptions flush_opts;
@ -4267,7 +4269,7 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
db_->GetProperty(DB::Properties::kNumEntriesActiveMemTable, &num_keys_in_memtable); db_->GetProperty(DB::Properties::kNumEntriesActiveMemTable, &num_keys_in_memtable);
ASSERT_EQ(ToString(1), num_keys_in_memtable); ASSERT_EQ(ToString(1), num_keys_in_memtable);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, CompactRangeFlushOverlappingMemtable) { TEST_F(DBCompactionTest, CompactRangeFlushOverlappingMemtable) {
@ -4509,29 +4511,29 @@ TEST_F(DBCompactionTest, CompactionLimiter) {
port::Mutex mutex; port::Mutex mutex;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:BeforeCompaction", [&](void* arg) { "DBImpl::BackgroundCompaction:BeforeCompaction", [&](void* arg) {
const auto& cf_name = static_cast<ColumnFamilyData*>(arg)->GetName(); const auto& cf_name = static_cast<ColumnFamilyData*>(arg)->GetName();
auto iter = cf_to_limiter.find(cf_name); auto iter = cf_to_limiter.find(cf_name);
if (iter != cf_to_limiter.end()) { if (iter != cf_to_limiter.end()) {
MutexLock l(&mutex); MutexLock l(&mutex);
ASSERT_GE(iter->second->limit_tasks, ++iter->second->tasks); ASSERT_GE(iter->second->limit_tasks, ++iter->second->tasks);
iter->second->max_tasks = std::max(iter->second->max_tasks, iter->second->max_tasks =
iter->second->limit_tasks); std::max(iter->second->max_tasks, iter->second->limit_tasks);
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:AfterCompaction", [&](void* arg) { "DBImpl::BackgroundCompaction:AfterCompaction", [&](void* arg) {
const auto& cf_name = static_cast<ColumnFamilyData*>(arg)->GetName(); const auto& cf_name = static_cast<ColumnFamilyData*>(arg)->GetName();
auto iter = cf_to_limiter.find(cf_name); auto iter = cf_to_limiter.find(cf_name);
if (iter != cf_to_limiter.end()) { if (iter != cf_to_limiter.end()) {
MutexLock l(&mutex); MutexLock l(&mutex);
ASSERT_GE(--iter->second->tasks, 0); ASSERT_GE(--iter->second->tasks, 0);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Block all compact threads in thread pool. // Block all compact threads in thread pool.
const size_t kTotalFlushTasks = kMaxBackgroundThreads / 4; const size_t kTotalFlushTasks = kMaxBackgroundThreads / 4;
@ -4869,12 +4871,10 @@ TEST_F(DBCompactionTest, CompactionDuringShutdown) {
Flush(); Flush();
} }
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:BeforeRun", "DBImpl::BackgroundCompaction:NonTrivial:BeforeRun",
[&](void* /*arg*/) { [&](void* /*arg*/) { dbfull()->shutting_down_.store(true); });
dbfull()->shutting_down_.store(true); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr); dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
ASSERT_OK(dbfull()->error_handler_.GetBGError()); ASSERT_OK(dbfull()->error_handler_.GetBGError());
} }
@ -4960,7 +4960,7 @@ TEST_F(DBCompactionTest, ConsistencyFailTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"VersionBuilder::CheckConsistency", [&](void* arg) { "VersionBuilder::CheckConsistency", [&](void* arg) {
auto p = auto p =
reinterpret_cast<std::pair<FileMetaData**, FileMetaData**>*>(arg); reinterpret_cast<std::pair<FileMetaData**, FileMetaData**>*>(arg);
@ -4971,7 +4971,7 @@ TEST_F(DBCompactionTest, ConsistencyFailTest) {
*(p->second) = temp; *(p->second) = temp;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int k = 0; k < 2; ++k) { for (int k = 0; k < 2; ++k) {
ASSERT_OK(Put("foo", "bar")); ASSERT_OK(Put("foo", "bar"));
@ -4979,7 +4979,7 @@ TEST_F(DBCompactionTest, ConsistencyFailTest) {
} }
ASSERT_NOK(Put("foo", "bar")); ASSERT_NOK(Put("foo", "bar"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
void IngestOneKeyValue(DBImpl* db, const std::string& key, void IngestOneKeyValue(DBImpl* db, const std::string& key,
@ -4987,7 +4987,7 @@ void IngestOneKeyValue(DBImpl* db, const std::string& key,
ExternalSstFileInfo info; ExternalSstFileInfo info;
std::string f = test::PerThreadDBPath("sst_file" + key); std::string f = test::PerThreadDBPath("sst_file" + key);
EnvOptions env; EnvOptions env;
rocksdb::SstFileWriter writer(env, options); ROCKSDB_NAMESPACE::SstFileWriter writer(env, options);
auto s = writer.Open(f); auto s = writer.Open(f);
ASSERT_OK(s); ASSERT_OK(s);
// ASSERT_OK(writer.Put(Key(), "")); // ASSERT_OK(writer.Put(Key(), ""));
@ -5014,14 +5014,14 @@ TEST_P(DBCompactionTestWithParam,
std::atomic<int> pick_intra_l0_count(0); std::atomic<int> pick_intra_l0_count(0);
std::string value(RandomString(&rnd, kValueSize)); std::string value(RandomString(&rnd, kValueSize));
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBCompactionTestWithParam::FlushAfterIntraL0:1", {{"DBCompactionTestWithParam::FlushAfterIntraL0:1",
"CompactionJob::Run():Start"}}); "CompactionJob::Run():Start"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"FindIntraL0Compaction", "FindIntraL0Compaction",
[&](void* /*arg*/) { pick_intra_l0_count.fetch_add(1); }); [&](void* /*arg*/) { pick_intra_l0_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// prevents trivial move // prevents trivial move
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@ -5056,7 +5056,7 @@ TEST_P(DBCompactionTestWithParam,
ASSERT_OK(Put(Key(2), "b")); ASSERT_OK(Put(Key(2), "b"));
ASSERT_EQ(10, NumTableFilesAtLevel(0)); ASSERT_EQ(10, NumTableFilesAtLevel(0));
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
std::vector<std::vector<FileMetaData>> level_to_files; std::vector<std::vector<FileMetaData>> level_to_files;
dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(), dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(),
&level_to_files); &level_to_files);
@ -5093,13 +5093,13 @@ TEST_P(DBCompactionTestWithParam,
ASSERT_EQ(0, NumTableFilesAtLevel(0)); ASSERT_EQ(0, NumTableFilesAtLevel(0));
std::atomic<int> pick_intra_l0_count(0); std::atomic<int> pick_intra_l0_count(0);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBCompactionTestWithParam::IntraL0CompactionAfterFlush:1", {{"DBCompactionTestWithParam::IntraL0CompactionAfterFlush:1",
"CompactionJob::Run():Start"}}); "CompactionJob::Run():Start"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"FindIntraL0Compaction", "FindIntraL0Compaction",
[&](void* /*arg*/) { pick_intra_l0_count.fetch_add(1); }); [&](void* /*arg*/) { pick_intra_l0_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Make 6 L0 sst. // Make 6 L0 sst.
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
if (i % 2 == 0) { if (i % 2 == 0) {
@ -5137,7 +5137,7 @@ TEST_P(DBCompactionTestWithParam,
sleeping_tasks.WaitUntilDone(); sleeping_tasks.WaitUntilDone();
TEST_SYNC_POINT("DBCompactionTestWithParam::IntraL0CompactionAfterFlush:1"); TEST_SYNC_POINT("DBCompactionTestWithParam::IntraL0CompactionAfterFlush:1");
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
uint64_t error_count = 0; uint64_t error_count = 0;
db_->GetIntProperty("rocksdb.background-errors", &error_count); db_->GetIntProperty("rocksdb.background-errors", &error_count);
@ -5152,11 +5152,11 @@ TEST_P(DBCompactionTestWithParam,
} }
#endif // !defined(ROCKSDB_LITE) #endif // !defined(ROCKSDB_LITE)
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else #else

View File

@ -16,7 +16,7 @@
#include "port/port.h" #include "port/port.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTestDynamicLevel : public DBTestBase { class DBTestDynamicLevel : public DBTestBase {
public: public:
DBTestDynamicLevel() : DBTestBase("/db_dynamic_level_test") {} DBTestDynamicLevel() : DBTestBase("/db_dynamic_level_test") {}
@ -221,10 +221,10 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase2) {
// Make sure that the compaction starts before the last bit of data is // Make sure that the compaction starts before the last bit of data is
// flushed, so that the base level isn't raised to L1. // flushed, so that the base level isn't raised to L1.
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"CompactionJob::Run():Start", "DynamicLevelMaxBytesBase2:0"}, {"CompactionJob::Run():Start", "DynamicLevelMaxBytesBase2:0"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->SetOptions({ ASSERT_OK(dbfull()->SetOptions({
{"disable_auto_compactions", "false"}, {"disable_auto_compactions", "false"},
@ -235,20 +235,20 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase2) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
ASSERT_TRUE(db_->GetIntProperty("rocksdb.base-level", &int_prop)); ASSERT_TRUE(db_->GetIntProperty("rocksdb.base-level", &int_prop));
ASSERT_EQ(2U, int_prop); ASSERT_EQ(2U, int_prop);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
// Write more data until the base level changes to L1. There will be // Write more data until the base level changes to L1. There will be
// a manual compaction going on at the same time. // a manual compaction going on at the same time.
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"CompactionJob::Run():Start", "DynamicLevelMaxBytesBase2:1"}, {"CompactionJob::Run():Start", "DynamicLevelMaxBytesBase2:1"},
{"DynamicLevelMaxBytesBase2:2", "CompactionJob::Run():End"}, {"DynamicLevelMaxBytesBase2:2", "CompactionJob::Run():End"},
{"DynamicLevelMaxBytesBase2:compact_range_finish", {"DynamicLevelMaxBytesBase2:compact_range_finish",
"FlushJob::WriteLevel0Table"}, "FlushJob::WriteLevel0Table"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([this] { ROCKSDB_NAMESPACE::port::Thread thread([this] {
TEST_SYNC_POINT("DynamicLevelMaxBytesBase2:compact_range_start"); TEST_SYNC_POINT("DynamicLevelMaxBytesBase2:compact_range_start");
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr)); ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
TEST_SYNC_POINT("DynamicLevelMaxBytesBase2:compact_range_finish"); TEST_SYNC_POINT("DynamicLevelMaxBytesBase2:compact_range_finish");
@ -265,8 +265,8 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase2) {
thread.join(); thread.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
ASSERT_TRUE(db_->GetIntProperty("rocksdb.base-level", &int_prop)); ASSERT_TRUE(db_->GetIntProperty("rocksdb.base-level", &int_prop));
ASSERT_EQ(1U, int_prop); ASSERT_EQ(1U, int_prop);
@ -329,16 +329,16 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesCompactRange) {
ASSERT_TRUE(db_->GetProperty("rocksdb.num-files-at-level2", &str_prop)); ASSERT_TRUE(db_->GetProperty("rocksdb.num-files-at-level2", &str_prop));
ASSERT_EQ("0", str_prop); ASSERT_EQ("0", str_prop);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
std::set<int> output_levels; std::set<int> output_levels;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionPicker::CompactRange:Return", [&](void* arg) { "CompactionPicker::CompactRange:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
output_levels.insert(compaction->output_level()); output_levels.insert(compaction->output_level());
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr); dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
ASSERT_EQ(output_levels.size(), 2); ASSERT_EQ(output_levels.size(), 2);
@ -373,10 +373,10 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBaseInc) {
DestroyAndReopen(options); DestroyAndReopen(options);
int non_trivial = 0; int non_trivial = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", "DBImpl::BackgroundCompaction:NonTrivial",
[&](void* /*arg*/) { non_trivial++; }); [&](void* /*arg*/) { non_trivial++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
const int total_keys = 3000; const int total_keys = 3000;
@ -388,7 +388,7 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBaseInc) {
} }
Flush(); Flush();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(non_trivial, 0); ASSERT_EQ(non_trivial, 0);
@ -457,7 +457,7 @@ TEST_F(DBTestDynamicLevel, DISABLED_MigrateToDynamicLevelMaxBytesBase) {
compaction_finished = false; compaction_finished = false;
// Issue manual compaction in one thread and still verify DB state // Issue manual compaction in one thread and still verify DB state
// in main thread. // in main thread.
rocksdb::port::Thread t([&]() { ROCKSDB_NAMESPACE::port::Thread t([&]() {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
compact_options.change_level = true; compact_options.change_level = true;
compact_options.target_level = options.num_levels - 1; compact_options.target_level = options.num_levels - 1;
@ -488,13 +488,13 @@ TEST_F(DBTestDynamicLevel, DISABLED_MigrateToDynamicLevelMaxBytesBase) {
ASSERT_EQ(NumTableFilesAtLevel(1), 0); ASSERT_EQ(NumTableFilesAtLevel(1), 0);
ASSERT_EQ(NumTableFilesAtLevel(2), 0); ASSERT_EQ(NumTableFilesAtLevel(2), 0);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !defined(ROCKSDB_LITE) #endif // !defined(ROCKSDB_LITE)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else #else

View File

@ -12,7 +12,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBEncryptionTest : public DBTestBase { class DBEncryptionTest : public DBTestBase {
public: public:
@ -113,10 +113,10 @@ TEST_F(DBEncryptionTest, ReadEmptyFile) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -21,7 +21,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
Status DBImpl::DisableFileDeletions() { Status DBImpl::DisableFileDeletions() {
InstrumentedMutexLock l(&mutex_); InstrumentedMutexLock l(&mutex_);
@ -172,6 +172,6 @@ Status DBImpl::GetCurrentWalFile(std::unique_ptr<LogFile>* current_log_file) {
return wal_manager_.GetLiveWalFile(current_logfile_number, current_log_file); return wal_manager_.GetLiveWalFile(current_logfile_number, current_log_file);
} }
} } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

View File

@ -18,7 +18,7 @@
#include "util/cast_util.h" #include "util/cast_util.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBFlushTest : public DBTestBase { class DBFlushTest : public DBTestBase {
public: public:
@ -775,10 +775,10 @@ INSTANTIATE_TEST_CASE_P(DBFlushDirectIOTest, DBFlushDirectIOTest,
INSTANTIATE_TEST_CASE_P(DBAtomicFlushTest, DBAtomicFlushTest, testing::Bool()); INSTANTIATE_TEST_CASE_P(DBAtomicFlushTest, DBAtomicFlushTest, testing::Bool());
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -102,7 +102,7 @@
#include "util/stop_watch.h" #include "util/stop_watch.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
const std::string kDefaultColumnFamilyName("default"); const std::string kDefaultColumnFamilyName("default");
const std::string kPersistentStatsColumnFamilyName( const std::string kPersistentStatsColumnFamilyName(
@ -644,7 +644,7 @@ void DBImpl::StartTimedTasks() {
stats_dump_period_sec = mutable_db_options_.stats_dump_period_sec; stats_dump_period_sec = mutable_db_options_.stats_dump_period_sec;
if (stats_dump_period_sec > 0) { if (stats_dump_period_sec > 0) {
if (!thread_dump_stats_) { if (!thread_dump_stats_) {
thread_dump_stats_.reset(new rocksdb::RepeatableThread( thread_dump_stats_.reset(new ROCKSDB_NAMESPACE::RepeatableThread(
[this]() { DBImpl::DumpStats(); }, "dump_st", env_, [this]() { DBImpl::DumpStats(); }, "dump_st", env_,
static_cast<uint64_t>(stats_dump_period_sec) * kMicrosInSecond)); static_cast<uint64_t>(stats_dump_period_sec) * kMicrosInSecond));
} }
@ -652,7 +652,7 @@ void DBImpl::StartTimedTasks() {
stats_persist_period_sec = mutable_db_options_.stats_persist_period_sec; stats_persist_period_sec = mutable_db_options_.stats_persist_period_sec;
if (stats_persist_period_sec > 0) { if (stats_persist_period_sec > 0) {
if (!thread_persist_stats_) { if (!thread_persist_stats_) {
thread_persist_stats_.reset(new rocksdb::RepeatableThread( thread_persist_stats_.reset(new ROCKSDB_NAMESPACE::RepeatableThread(
[this]() { DBImpl::PersistStats(); }, "pst_st", env_, [this]() { DBImpl::PersistStats(); }, "pst_st", env_,
static_cast<uint64_t>(stats_persist_period_sec) * kMicrosInSecond)); static_cast<uint64_t>(stats_persist_period_sec) * kMicrosInSecond));
} }
@ -1043,7 +1043,7 @@ Status DBImpl::SetDBOptions(
mutex_.Lock(); mutex_.Lock();
} }
if (new_options.stats_dump_period_sec > 0) { if (new_options.stats_dump_period_sec > 0) {
thread_dump_stats_.reset(new rocksdb::RepeatableThread( thread_dump_stats_.reset(new ROCKSDB_NAMESPACE::RepeatableThread(
[this]() { DBImpl::DumpStats(); }, "dump_st", env_, [this]() { DBImpl::DumpStats(); }, "dump_st", env_,
static_cast<uint64_t>(new_options.stats_dump_period_sec) * static_cast<uint64_t>(new_options.stats_dump_period_sec) *
kMicrosInSecond)); kMicrosInSecond));
@ -1059,7 +1059,7 @@ Status DBImpl::SetDBOptions(
mutex_.Lock(); mutex_.Lock();
} }
if (new_options.stats_persist_period_sec > 0) { if (new_options.stats_persist_period_sec > 0) {
thread_persist_stats_.reset(new rocksdb::RepeatableThread( thread_persist_stats_.reset(new ROCKSDB_NAMESPACE::RepeatableThread(
[this]() { DBImpl::PersistStats(); }, "pst_st", env_, [this]() { DBImpl::PersistStats(); }, "pst_st", env_,
static_cast<uint64_t>(new_options.stats_persist_period_sec) * static_cast<uint64_t>(new_options.stats_persist_period_sec) *
kMicrosInSecond)); kMicrosInSecond));
@ -4376,8 +4376,8 @@ Status DBImpl::VerifyChecksum(const ReadOptions& read_options) {
const auto& fd = vstorage->LevelFilesBrief(i).files[j].fd; const auto& fd = vstorage->LevelFilesBrief(i).files[j].fd;
std::string fname = TableFileName(cfd->ioptions()->cf_paths, std::string fname = TableFileName(cfd->ioptions()->cf_paths,
fd.GetNumber(), fd.GetPathId()); fd.GetNumber(), fd.GetPathId());
s = rocksdb::VerifySstFileChecksum(opts, file_options_, read_options, s = ROCKSDB_NAMESPACE::VerifySstFileChecksum(opts, file_options_,
fname); read_options, fname);
} }
} }
if (!s.ok()) { if (!s.ok()) {
@ -4539,4 +4539,4 @@ Status DBImpl::GetCreationTimeOfOldestFile(uint64_t* creation_time) {
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -62,7 +62,7 @@
#include "util/stop_watch.h" #include "util/stop_watch.h"
#include "util/thread_local.h" #include "util/thread_local.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class Arena; class Arena;
class ArenaWrappedDBIter; class ArenaWrappedDBIter;
@ -2015,11 +2015,11 @@ class DBImpl : public DB {
// handle for scheduling stats dumping at fixed intervals // handle for scheduling stats dumping at fixed intervals
// REQUIRES: mutex locked // REQUIRES: mutex locked
std::unique_ptr<rocksdb::RepeatableThread> thread_dump_stats_; std::unique_ptr<ROCKSDB_NAMESPACE::RepeatableThread> thread_dump_stats_;
// handle for scheduling stats snapshoting at fixed intervals // handle for scheduling stats snapshoting at fixed intervals
// REQUIRES: mutex locked // REQUIRES: mutex locked
std::unique_ptr<rocksdb::RepeatableThread> thread_persist_stats_; std::unique_ptr<ROCKSDB_NAMESPACE::RepeatableThread> thread_persist_stats_;
// When set, we use a separate queue for writes that dont write to memtable. // When set, we use a separate queue for writes that dont write to memtable.
// In 2PC these are the writes at Prepare phase. // In 2PC these are the writes at Prepare phase.
@ -2104,4 +2104,4 @@ static void ClipToRange(T* ptr, V minvalue, V maxvalue) {
if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue; if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -22,7 +22,7 @@
#include "util/cast_util.h" #include "util/cast_util.h"
#include "util/concurrent_task_limiter_impl.h" #include "util/concurrent_task_limiter_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
bool DBImpl::EnoughRoomForCompaction( bool DBImpl::EnoughRoomForCompaction(
ColumnFamilyData* cfd, const std::vector<CompactionInputFiles>& inputs, ColumnFamilyData* cfd, const std::vector<CompactionInputFiles>& inputs,
@ -3113,4 +3113,4 @@ void DBImpl::GetSnapshotContext(
} }
*snapshot_seqs = snapshots_.GetAll(earliest_write_conflict_snapshot); *snapshot_seqs = snapshots_.GetAll(earliest_write_conflict_snapshot);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -15,7 +15,7 @@
#include "monitoring/thread_status_updater.h" #include "monitoring/thread_status_updater.h"
#include "util/cast_util.h" #include "util/cast_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
uint64_t DBImpl::TEST_GetLevel0TotalSize() { uint64_t DBImpl::TEST_GetLevel0TotalSize() {
InstrumentedMutexLock l(&mutex_); InstrumentedMutexLock l(&mutex_);
return default_cf_handle_->cfd()->current()->storage_info()->NumLevelBytes(0); return default_cf_handle_->cfd()->current()->storage_info()->NumLevelBytes(0);
@ -290,5 +290,5 @@ bool DBImpl::TEST_IsPersistentStatsEnabled() const {
size_t DBImpl::TEST_EstimateInMemoryStatsHistorySize() const { size_t DBImpl::TEST_EstimateInMemoryStatsHistorySize() const {
return EstimateInMemoryStatsHistorySize(); return EstimateInMemoryStatsHistorySize();
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // NDEBUG #endif // NDEBUG

View File

@ -17,7 +17,7 @@
#include "db/version_set.h" #include "db/version_set.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
Status DBImpl::SuggestCompactRange(ColumnFamilyHandle* column_family, Status DBImpl::SuggestCompactRange(ColumnFamilyHandle* column_family,
@ -148,4 +148,4 @@ Status DBImpl::PromoteL0(ColumnFamilyHandle* column_family, int target_level) {
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -17,7 +17,7 @@
#include "file/sst_file_manager_impl.h" #include "file/sst_file_manager_impl.h"
#include "util/autovector.h" #include "util/autovector.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
uint64_t DBImpl::MinLogNumberToKeep() { uint64_t DBImpl::MinLogNumberToKeep() {
if (allow_2pc()) { if (allow_2pc()) {
@ -664,4 +664,4 @@ uint64_t PrecomputeMinLogNumberToKeep(
return min_log_number_to_keep; return min_log_number_to_keep;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -23,7 +23,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/rate_limiter.h" #include "util/rate_limiter.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
Options SanitizeOptions(const std::string& dbname, const Options& src) { Options SanitizeOptions(const std::string& dbname, const Options& src) {
auto db_options = SanitizeOptions(dbname, DBOptions(src)); auto db_options = SanitizeOptions(dbname, DBOptions(src));
ImmutableDBOptions immutable_db_options(db_options); ImmutableDBOptions immutable_db_options(db_options);
@ -1648,4 +1648,4 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
} }
return s; return s;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -12,7 +12,7 @@
#include "db/merge_context.h" #include "db/merge_context.h"
#include "monitoring/perf_context_imp.h" #include "monitoring/perf_context_imp.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -218,4 +218,4 @@ Status DB::OpenForReadOnly(
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -11,7 +11,7 @@
#include <vector> #include <vector>
#include "db/db_impl/db_impl.h" #include "db/db_impl/db_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBImplReadOnly : public DBImpl { class DBImplReadOnly : public DBImpl {
public: public:
@ -132,6 +132,6 @@ class DBImplReadOnly : public DBImpl {
private: private:
friend class DB; friend class DB;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -13,7 +13,7 @@
#include "monitoring/perf_context_imp.h" #include "monitoring/perf_context_imp.h"
#include "util/cast_util.h" #include "util/cast_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
DBImplSecondary::DBImplSecondary(const DBOptions& db_options, DBImplSecondary::DBImplSecondary(const DBOptions& db_options,
@ -668,4 +668,4 @@ Status DB::OpenAsSecondary(
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -11,7 +11,7 @@
#include <vector> #include <vector>
#include "db/db_impl/db_impl.h" #include "db/db_impl/db_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// A wrapper class to hold log reader, log reporter, log status. // A wrapper class to hold log reader, log reporter, log status.
class LogReaderContainer { class LogReaderContainer {
@ -328,6 +328,6 @@ class DBImplSecondary : public DBImpl {
std::unordered_map<ColumnFamilyData*, uint64_t> cfd_to_current_log_; std::unordered_map<ColumnFamilyData*, uint64_t> cfd_to_current_log_;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

View File

@ -15,7 +15,7 @@
#include "options/options_helper.h" #include "options/options_helper.h"
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Convenience methods // Convenience methods
Status DBImpl::Put(const WriteOptions& o, ColumnFamilyHandle* column_family, Status DBImpl::Put(const WriteOptions& o, ColumnFamilyHandle* column_family,
const Slice& key, const Slice& val) { const Slice& key, const Slice& val) {
@ -1836,4 +1836,4 @@ Status DB::Merge(const WriteOptions& opt, ColumnFamilyHandle* column_family,
} }
return Write(opt, &batch); return Write(opt, &batch);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -13,7 +13,7 @@
#include "test_util/fault_injection_test_env.h" #include "test_util/fault_injection_test_env.h"
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
class DBSecondaryTest : public DBTestBase { class DBSecondaryTest : public DBTestBase {
@ -860,10 +860,10 @@ TEST_F(DBSecondaryTest, CheckConsistencyWhenOpen) {
} }
#endif //! ROCKSDB_LITE #endif //! ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -14,7 +14,7 @@
#include "file/filename.h" #include "file/filename.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
void DumpDBFileSummary(const ImmutableDBOptions& options, void DumpDBFileSummary(const ImmutableDBOptions& options,
const std::string& dbname) { const std::string& dbname) {
@ -120,4 +120,4 @@ void DumpDBFileSummary(const ImmutableDBOptions& options,
Header(options.info_log, "Write Ahead Log file in %s: %s\n", Header(options.info_log, "Write Ahead Log file in %s: %s\n",
options.wal_dir.c_str(), wal_info.c_str()); options.wal_dir.c_str(), wal_info.c_str());
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -8,7 +8,7 @@
#include "options/db_options.h" #include "options/db_options.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
void DumpDBFileSummary(const ImmutableDBOptions& options, void DumpDBFileSummary(const ImmutableDBOptions& options,
const std::string& dbname); const std::string& dbname);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -9,7 +9,7 @@
#include "db/db_test_util.h" #include "db/db_test_util.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTestInPlaceUpdate : public DBTestBase { class DBTestInPlaceUpdate : public DBTestBase {
public: public:
@ -73,7 +73,7 @@ TEST_F(DBTestInPlaceUpdate, InPlaceUpdateCallbackSmallerSize) {
options.env = env_; options.env = env_;
options.write_buffer_size = 100000; options.write_buffer_size = 100000;
options.inplace_callback = options.inplace_callback =
rocksdb::DBTestInPlaceUpdate::updateInPlaceSmallerSize; ROCKSDB_NAMESPACE::DBTestInPlaceUpdate::updateInPlaceSmallerSize;
options.allow_concurrent_memtable_write = false; options.allow_concurrent_memtable_write = false;
Reopen(options); Reopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -102,7 +102,7 @@ TEST_F(DBTestInPlaceUpdate, InPlaceUpdateCallbackSmallerVarintSize) {
options.env = env_; options.env = env_;
options.write_buffer_size = 100000; options.write_buffer_size = 100000;
options.inplace_callback = options.inplace_callback =
rocksdb::DBTestInPlaceUpdate::updateInPlaceSmallerVarintSize; ROCKSDB_NAMESPACE::DBTestInPlaceUpdate::updateInPlaceSmallerVarintSize;
options.allow_concurrent_memtable_write = false; options.allow_concurrent_memtable_write = false;
Reopen(options); Reopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -131,7 +131,7 @@ TEST_F(DBTestInPlaceUpdate, InPlaceUpdateCallbackLargeNewValue) {
options.env = env_; options.env = env_;
options.write_buffer_size = 100000; options.write_buffer_size = 100000;
options.inplace_callback = options.inplace_callback =
rocksdb::DBTestInPlaceUpdate::updateInPlaceLargerSize; ROCKSDB_NAMESPACE::DBTestInPlaceUpdate::updateInPlaceLargerSize;
options.allow_concurrent_memtable_write = false; options.allow_concurrent_memtable_write = false;
Reopen(options); Reopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -158,7 +158,7 @@ TEST_F(DBTestInPlaceUpdate, InPlaceUpdateCallbackNoAction) {
options.env = env_; options.env = env_;
options.write_buffer_size = 100000; options.write_buffer_size = 100000;
options.inplace_callback = options.inplace_callback =
rocksdb::DBTestInPlaceUpdate::updateInPlaceNoAction; ROCKSDB_NAMESPACE::DBTestInPlaceUpdate::updateInPlaceNoAction;
options.allow_concurrent_memtable_write = false; options.allow_concurrent_memtable_write = false;
Reopen(options); Reopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -168,10 +168,10 @@ TEST_F(DBTestInPlaceUpdate, InPlaceUpdateCallbackNoAction) {
ASSERT_EQ(Get(1, "key"), "NOT_FOUND"); ASSERT_EQ(Get(1, "key"), "NOT_FOUND");
} while (ChangeCompactOptions()); } while (ChangeCompactOptions());
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -10,7 +10,7 @@
#include "db/db_test_util.h" #include "db/db_test_util.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBIOFailureTest : public DBTestBase { class DBIOFailureTest : public DBTestBase {
public: public:
@ -270,14 +270,14 @@ TEST_F(DBIOFailureTest, FlushSstRangeSyncError) {
Status s; Status s;
std::atomic<int> range_sync_called(0); std::atomic<int> range_sync_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::RangeSync", [&](void* arg) { "SpecialEnv::SStableFile::RangeSync", [&](void* arg) {
if (range_sync_called.fetch_add(1) == 0) { if (range_sync_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
*st = Status::IOError("range sync dummy error"); *st = Status::IOError("range sync dummy error");
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
std::string rnd_str = std::string rnd_str =
@ -302,7 +302,7 @@ TEST_F(DBIOFailureTest, FlushSstRangeSyncError) {
ASSERT_NOK(Put(1, "foo2", "bar3")); ASSERT_NOK(Put(1, "foo2", "bar3"));
ASSERT_EQ("bar", Get(1, "foo")); ASSERT_EQ("bar", Get(1, "foo"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_GE(1, range_sync_called.load()); ASSERT_GE(1, range_sync_called.load());
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
@ -350,14 +350,14 @@ TEST_F(DBIOFailureTest, CompactSstRangeSyncError) {
dbfull()->TEST_WaitForFlushMemTable(handles_[1]); dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
std::atomic<int> range_sync_called(0); std::atomic<int> range_sync_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::RangeSync", [&](void* arg) { "SpecialEnv::SStableFile::RangeSync", [&](void* arg) {
if (range_sync_called.fetch_add(1) == 0) { if (range_sync_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
*st = Status::IOError("range sync dummy error"); *st = Status::IOError("range sync dummy error");
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->SetOptions(handles_[1], ASSERT_OK(dbfull()->SetOptions(handles_[1],
{ {
@ -369,7 +369,7 @@ TEST_F(DBIOFailureTest, CompactSstRangeSyncError) {
ASSERT_NOK(Put(1, "foo2", "bar3")); ASSERT_NOK(Put(1, "foo2", "bar3"));
ASSERT_EQ("bar", Get(1, "foo")); ASSERT_EQ("bar", Get(1, "foo"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_GE(1, range_sync_called.load()); ASSERT_GE(1, range_sync_called.load());
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
@ -389,7 +389,7 @@ TEST_F(DBIOFailureTest, FlushSstCloseError) {
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
Status s; Status s;
std::atomic<int> close_called(0); std::atomic<int> close_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::Close", [&](void* arg) { "SpecialEnv::SStableFile::Close", [&](void* arg) {
if (close_called.fetch_add(1) == 0) { if (close_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
@ -397,7 +397,7 @@ TEST_F(DBIOFailureTest, FlushSstCloseError) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(Put(1, "foo", "bar")); ASSERT_OK(Put(1, "foo", "bar"));
ASSERT_OK(Put(1, "foo1", "bar1")); ASSERT_OK(Put(1, "foo1", "bar1"));
@ -409,7 +409,7 @@ TEST_F(DBIOFailureTest, FlushSstCloseError) {
ASSERT_EQ("bar2", Get(1, "foo")); ASSERT_EQ("bar2", Get(1, "foo"));
ASSERT_EQ("bar1", Get(1, "foo1")); ASSERT_EQ("bar1", Get(1, "foo1"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
ASSERT_EQ("bar2", Get(1, "foo")); ASSERT_EQ("bar2", Get(1, "foo"));
@ -441,7 +441,7 @@ TEST_F(DBIOFailureTest, CompactionSstCloseError) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
std::atomic<int> close_called(0); std::atomic<int> close_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::Close", [&](void* arg) { "SpecialEnv::SStableFile::Close", [&](void* arg) {
if (close_called.fetch_add(1) == 0) { if (close_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
@ -449,7 +449,7 @@ TEST_F(DBIOFailureTest, CompactionSstCloseError) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->SetOptions(handles_[1], ASSERT_OK(dbfull()->SetOptions(handles_[1],
{ {
{"disable_auto_compactions", "false"}, {"disable_auto_compactions", "false"},
@ -460,7 +460,7 @@ TEST_F(DBIOFailureTest, CompactionSstCloseError) {
ASSERT_NOK(Put(1, "foo2", "bar3")); ASSERT_NOK(Put(1, "foo2", "bar3"));
ASSERT_EQ("bar3", Get(1, "foo")); ASSERT_EQ("bar3", Get(1, "foo"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
ASSERT_EQ("bar3", Get(1, "foo")); ASSERT_EQ("bar3", Get(1, "foo"));
@ -480,7 +480,7 @@ TEST_F(DBIOFailureTest, FlushSstSyncError) {
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
Status s; Status s;
std::atomic<int> sync_called(0); std::atomic<int> sync_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::Sync", [&](void* arg) { "SpecialEnv::SStableFile::Sync", [&](void* arg) {
if (sync_called.fetch_add(1) == 0) { if (sync_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
@ -488,7 +488,7 @@ TEST_F(DBIOFailureTest, FlushSstSyncError) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(Put(1, "foo", "bar")); ASSERT_OK(Put(1, "foo", "bar"));
ASSERT_OK(Put(1, "foo1", "bar1")); ASSERT_OK(Put(1, "foo1", "bar1"));
@ -500,7 +500,7 @@ TEST_F(DBIOFailureTest, FlushSstSyncError) {
ASSERT_EQ("bar2", Get(1, "foo")); ASSERT_EQ("bar2", Get(1, "foo"));
ASSERT_EQ("bar1", Get(1, "foo1")); ASSERT_EQ("bar1", Get(1, "foo1"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
ASSERT_EQ("bar2", Get(1, "foo")); ASSERT_EQ("bar2", Get(1, "foo"));
@ -533,7 +533,7 @@ TEST_F(DBIOFailureTest, CompactionSstSyncError) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
std::atomic<int> sync_called(0); std::atomic<int> sync_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SpecialEnv::SStableFile::Sync", [&](void* arg) { "SpecialEnv::SStableFile::Sync", [&](void* arg) {
if (sync_called.fetch_add(1) == 0) { if (sync_called.fetch_add(1) == 0) {
Status* st = static_cast<Status*>(arg); Status* st = static_cast<Status*>(arg);
@ -541,7 +541,7 @@ TEST_F(DBIOFailureTest, CompactionSstSyncError) {
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->SetOptions(handles_[1], ASSERT_OK(dbfull()->SetOptions(handles_[1],
{ {
{"disable_auto_compactions", "false"}, {"disable_auto_compactions", "false"},
@ -552,17 +552,17 @@ TEST_F(DBIOFailureTest, CompactionSstSyncError) {
ASSERT_NOK(Put(1, "foo2", "bar3")); ASSERT_NOK(Put(1, "foo2", "bar3"));
ASSERT_EQ("bar3", Get(1, "foo")); ASSERT_EQ("bar3", Get(1, "foo"));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
ASSERT_EQ("bar3", Get(1, "foo")); ASSERT_EQ("bar3", Get(1, "foo"));
} }
#endif // !(defined NDEBUG) || !defined(OS_WIN) #endif // !(defined NDEBUG) || !defined(OS_WIN)
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -31,7 +31,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "util/user_comparator_wrapper.h" #include "util/user_comparator_wrapper.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
#if 0 #if 0
static void DumpInternalIter(Iterator* iter) { static void DumpInternalIter(Iterator* iter) {
@ -325,7 +325,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
valid_ = false; valid_ = false;
return false; return false;
} }
@ -497,7 +497,7 @@ bool DBIter::MergeValuesNewToOld() {
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
} else { } else {
status_ = status_ =
Status::NotSupported("Blob DB does not support merge operator."); Status::NotSupported("Blob DB does not support merge operator.");
@ -798,7 +798,7 @@ bool DBIter::FindValueForCurrentKey() {
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
} else { } else {
status_ = status_ =
Status::NotSupported("Blob DB does not support merge operator."); Status::NotSupported("Blob DB does not support merge operator.");
@ -821,7 +821,7 @@ bool DBIter::FindValueForCurrentKey() {
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
valid_ = false; valid_ = false;
return false; return false;
} }
@ -892,7 +892,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
valid_ = false; valid_ = false;
return false; return false;
} }
@ -954,7 +954,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index."); ROCKS_LOG_ERROR(logger_, "Encounter unexpected blob index.");
status_ = Status::NotSupported( status_ = Status::NotSupported(
"Encounter unexpected blob index. Please open DB with " "Encounter unexpected blob index. Please open DB with "
"rocksdb::blob_db::BlobDB instead."); "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
} else { } else {
status_ = status_ =
Status::NotSupported("Blob DB does not support merge operator."); Status::NotSupported("Blob DB does not support merge operator.");
@ -1324,4 +1324,4 @@ Iterator* NewDBIterator(Env* env, const ReadOptions& read_options,
return db_iter; return db_iter;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -20,7 +20,7 @@
#include "table/iterator_wrapper.h" #include "table/iterator_wrapper.h"
#include "util/autovector.h" #include "util/autovector.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// This file declares the factory functions of DBIter, in its original form // This file declares the factory functions of DBIter, in its original form
// or a wrapped form with class ArenaWrappedDBIter, which is defined here. // or a wrapped form with class ArenaWrappedDBIter, which is defined here.
@ -342,4 +342,4 @@ extern Iterator* NewDBIterator(
ReadCallback* read_callback, DBImpl* db_impl = nullptr, ReadCallback* read_callback, DBImpl* db_impl = nullptr,
ColumnFamilyData* cfd = nullptr, bool allow_blob = false); ColumnFamilyData* cfd = nullptr, bool allow_blob = false);
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -29,7 +29,7 @@ bool FLAGS_verbose = false;
#endif #endif
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBIteratorStressTest : public testing::Test { class DBIteratorStressTest : public testing::Test {
public: public:
@ -645,7 +645,7 @@ TEST_F(DBIteratorStressTest, StressTest) {
<< "\n mutated on the fly: " << num_recently_removed << std::endl; << "\n mutated on the fly: " << num_recently_removed << std::endl;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -22,7 +22,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static uint64_t TestGetTickerCount(const Options& options, static uint64_t TestGetTickerCount(const Options& options,
Tickers ticker_type) { Tickers ticker_type) {
@ -691,7 +691,7 @@ TEST_F(DBIteratorTest, DBIteratorEmpty) {
TEST_F(DBIteratorTest, DBIteratorUseSkipCountSkips) { TEST_F(DBIteratorTest, DBIteratorUseSkipCountSkips) {
ReadOptions ro; ReadOptions ro;
Options options; Options options;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.merge_operator = MergeOperators::CreateFromStringId("stringappend"); options.merge_operator = MergeOperators::CreateFromStringId("stringappend");
TestIterator* internal_iter = new TestIterator(BytewiseComparator()); TestIterator* internal_iter = new TestIterator(BytewiseComparator());
@ -746,7 +746,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
} }
internal_iter->Finish(); internal_iter->Finish();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
std::unique_ptr<Iterator> db_iter(NewDBIterator( std::unique_ptr<Iterator> db_iter(NewDBIterator(
env_, ro, cf_options, mutable_cf_options, BytewiseComparator(), env_, ro, cf_options, mutable_cf_options, BytewiseComparator(),
internal_iter, i + 2, options.max_sequential_skip_in_iterations, internal_iter, i + 2, options.max_sequential_skip_in_iterations,
@ -2481,7 +2481,7 @@ TEST_F(DBIteratorTest, DBIteratorTestDifferentialSnapshots) {
ReadOptions ro; ReadOptions ro;
ro.iter_start_seqnum=5; ro.iter_start_seqnum=5;
Options options; Options options;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
TestIterator* internal_iter = new TestIterator(BytewiseComparator()); TestIterator* internal_iter = new TestIterator(BytewiseComparator());
for (size_t i = 0; i < 10; ++i) { for (size_t i = 0; i < 10; ++i) {
@ -2516,7 +2516,7 @@ TEST_F(DBIteratorTest, DBIteratorTestDifferentialSnapshots) {
ReadOptions ro; ReadOptions ro;
ro.iter_start_seqnum=5; ro.iter_start_seqnum=5;
Options options; Options options;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
TestIterator* internal_iter = new TestIterator(BytewiseComparator()); TestIterator* internal_iter = new TestIterator(BytewiseComparator());
for (size_t i = 0; i < 10; ++i) { for (size_t i = 0; i < 10; ++i) {
@ -2661,10 +2661,10 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
// Test call back inserts a key in the end of the mem table after // Test call back inserts a key in the end of the mem table after
// MergeIterator::Prev() realized the mem table iterator is at its end // MergeIterator::Prev() realized the mem table iterator is at its end
// and before an SeekToLast() is called. // and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", "MergeIterator::Prev:BeforePrev",
[&](void* /*arg*/) { internal_iter2_->Add("z", kTypeValue, "7", 12u); }); [&](void* /*arg*/) { internal_iter2_->Add("z", kTypeValue, "7", 12u); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2683,7 +2683,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
@ -2697,12 +2697,12 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
// Test call back inserts entries for update a key in the end of the // Test call back inserts entries for update a key in the end of the
// mem table after MergeIterator::Prev() realized the mem tableiterator is at // mem table after MergeIterator::Prev() realized the mem tableiterator is at
// its end and before an SeekToLast() is called. // its end and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* /*arg*/) { "MergeIterator::Prev:BeforePrev", [&](void* /*arg*/) {
internal_iter2_->Add("z", kTypeValue, "7", 12u); internal_iter2_->Add("z", kTypeValue, "7", 12u);
internal_iter2_->Add("z", kTypeValue, "7", 11u); internal_iter2_->Add("z", kTypeValue, "7", 11u);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2721,7 +2721,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
@ -2735,7 +2735,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
// Test call back inserts entries for update a key in the end of the // Test call back inserts entries for update a key in the end of the
// mem table after MergeIterator::Prev() realized the mem table iterator is at // mem table after MergeIterator::Prev() realized the mem table iterator is at
// its end and before an SeekToLast() is called. // its end and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* /*arg*/) { "MergeIterator::Prev:BeforePrev", [&](void* /*arg*/) {
internal_iter2_->Add("z", kTypeValue, "7", 16u, true); internal_iter2_->Add("z", kTypeValue, "7", 16u, true);
internal_iter2_->Add("z", kTypeValue, "7", 15u, true); internal_iter2_->Add("z", kTypeValue, "7", 15u, true);
@ -2744,7 +2744,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
internal_iter2_->Add("z", kTypeValue, "7", 12u, true); internal_iter2_->Add("z", kTypeValue, "7", 12u, true);
internal_iter2_->Add("z", kTypeValue, "7", 11u, true); internal_iter2_->Add("z", kTypeValue, "7", 11u, true);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2763,7 +2763,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
@ -2779,7 +2779,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
// Test call back inserts entries for update a key before "z" in // Test call back inserts entries for update a key before "z" in
// mem table after MergeIterator::Prev() calls mem table iterator's // mem table after MergeIterator::Prev() calls mem table iterator's
// Seek() and before calling Prev() // Seek() and before calling Prev()
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* arg) { "MergeIterator::Prev:BeforePrev", [&](void* arg) {
IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg); IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg);
if (it->key().starts_with("z")) { if (it->key().starts_with("z")) {
@ -2791,7 +2791,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
internal_iter2_->Add("x", kTypeValue, "7", 11u, true); internal_iter2_->Add("x", kTypeValue, "7", 11u, true);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2814,7 +2814,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace4) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
@ -2830,7 +2830,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
// Test call back inserts entries for update a key before "z" in // Test call back inserts entries for update a key before "z" in
// mem table after MergeIterator::Prev() calls mem table iterator's // mem table after MergeIterator::Prev() calls mem table iterator's
// Seek() and before calling Prev() // Seek() and before calling Prev()
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* arg) { "MergeIterator::Prev:BeforePrev", [&](void* arg) {
IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg); IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg);
if (it->key().starts_with("z")) { if (it->key().starts_with("z")) {
@ -2838,7 +2838,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
internal_iter2_->Add("x", kTypeValue, "7", 15u, true); internal_iter2_->Add("x", kTypeValue, "7", 15u, true);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2861,7 +2861,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace5) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) {
@ -2877,14 +2877,14 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) {
// Test call back inserts an entry for update a key before "z" in // Test call back inserts an entry for update a key before "z" in
// mem table after MergeIterator::Prev() calls mem table iterator's // mem table after MergeIterator::Prev() calls mem table iterator's
// Seek() and before calling Prev() // Seek() and before calling Prev()
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* arg) { "MergeIterator::Prev:BeforePrev", [&](void* arg) {
IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg); IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg);
if (it->key().starts_with("z")) { if (it->key().starts_with("z")) {
internal_iter2_->Add("x", kTypeValue, "7", 16u, true); internal_iter2_->Add("x", kTypeValue, "7", 16u, true);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2907,7 +2907,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace6) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
@ -2926,7 +2926,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
// Test call back inserts entries for update a key before "z" in // Test call back inserts entries for update a key before "z" in
// mem table after MergeIterator::Prev() calls mem table iterator's // mem table after MergeIterator::Prev() calls mem table iterator's
// Seek() and before calling Prev() // Seek() and before calling Prev()
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* arg) { "MergeIterator::Prev:BeforePrev", [&](void* arg) {
IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg); IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg);
if (it->key().starts_with("z")) { if (it->key().starts_with("z")) {
@ -2938,7 +2938,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
internal_iter2_->Add("x", kTypeValue, "7", 11u, true); internal_iter2_->Add("x", kTypeValue, "7", 11u, true);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2961,7 +2961,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace7) {
ASSERT_EQ(db_iter_->key().ToString(), "a"); ASSERT_EQ(db_iter_->key().ToString(), "a");
ASSERT_EQ(db_iter_->value().ToString(), "4"); ASSERT_EQ(db_iter_->value().ToString(), "4");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) { TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
@ -2979,7 +2979,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
// Test call back inserts two keys before "z" in mem table after // Test call back inserts two keys before "z" in mem table after
// MergeIterator::Prev() calls mem table iterator's Seek() and // MergeIterator::Prev() calls mem table iterator's Seek() and
// before calling Prev() // before calling Prev()
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforePrev", [&](void* arg) { "MergeIterator::Prev:BeforePrev", [&](void* arg) {
IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg); IteratorWrapper* it = reinterpret_cast<IteratorWrapper*>(arg);
if (it->key().starts_with("z")) { if (it->key().starts_with("z")) {
@ -2987,7 +2987,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
internal_iter2_->Add("y", kTypeValue, "7", 17u, true); internal_iter2_->Add("y", kTypeValue, "7", 17u, true);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev(); db_iter_->Prev();
ASSERT_TRUE(db_iter_->Valid()); ASSERT_TRUE(db_iter_->Valid());
@ -2998,7 +2998,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
ASSERT_EQ(db_iter_->key().ToString(), "d"); ASSERT_EQ(db_iter_->key().ToString(), "d");
ASSERT_EQ(db_iter_->value().ToString(), "7"); ASSERT_EQ(db_iter_->value().ToString(), "7");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
@ -3167,7 +3167,7 @@ TEST_F(DBIteratorTest, ReverseToForwardWithDisappearingKeys) {
EXPECT_LT(internal_iter->steps(), 20); EXPECT_LT(internal_iter->steps(), 20);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -18,7 +18,7 @@
#include "rocksdb/perf_context.h" #include "rocksdb/perf_context.h"
#include "table/block_based/flush_block_policy.h" #include "table/block_based/flush_block_policy.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// A dumb ReadCallback which saying every key is committed. // A dumb ReadCallback which saying every key is committed.
class DummyReadCallback : public ReadCallback { class DummyReadCallback : public ReadCallback {
@ -109,7 +109,7 @@ TEST_P(DBIteratorTest, NonBlockingIteration) {
do { do {
ReadOptions non_blocking_opts, regular_opts; ReadOptions non_blocking_opts, regular_opts;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
non_blocking_opts.read_tier = kBlockCacheTier; non_blocking_opts.read_tier = kBlockCacheTier;
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
// write one kv to the database. // write one kv to the database.
@ -535,7 +535,7 @@ TEST_P(DBIteratorTest, IterReseek) {
Options options = CurrentOptions(options_override); Options options = CurrentOptions(options_override);
options.max_sequential_skip_in_iterations = 3; options.max_sequential_skip_in_iterations = 3;
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -1026,7 +1026,7 @@ TEST_P(DBIteratorTest, DBIteratorBoundMultiSeek) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.env = env_; options.env = env_;
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.prefix_extractor = nullptr; options.prefix_extractor = nullptr;
DestroyAndReopen(options); DestroyAndReopen(options);
ASSERT_OK(Put("a", "0")); ASSERT_OK(Put("a", "0"));
@ -1081,10 +1081,10 @@ TEST_P(DBIteratorTest, DBIteratorBoundOptimizationTest) {
for (auto format_version : {2, 3, 4}) { for (auto format_version : {2, 3, 4}) {
int upper_bound_hits = 0; int upper_bound_hits = 0;
Options options = CurrentOptions(); Options options = CurrentOptions();
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BlockBasedTableIterator:out_of_bound", "BlockBasedTableIterator:out_of_bound",
[&upper_bound_hits](void*) { upper_bound_hits++; }); [&upper_bound_hits](void*) { upper_bound_hits++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
options.env = env_; options.env = env_;
options.create_if_missing = true; options.create_if_missing = true;
options.prefix_extractor = nullptr; options.prefix_extractor = nullptr;
@ -1132,7 +1132,7 @@ TEST_P(DBIteratorTest, IndexWithFirstKey) {
options.create_if_missing = true; options.create_if_missing = true;
options.prefix_extractor = nullptr; options.prefix_extractor = nullptr;
options.merge_operator = MergeOperators::CreateStringAppendOperator(); options.merge_operator = MergeOperators::CreateStringAppendOperator();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
Statistics* stats = options.statistics.get(); Statistics* stats = options.statistics.get();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.index_type = table_options.index_type =
@ -1223,7 +1223,7 @@ TEST_P(DBIteratorTest, IndexWithFirstKeyGet) {
options.create_if_missing = true; options.create_if_missing = true;
options.prefix_extractor = nullptr; options.prefix_extractor = nullptr;
options.merge_operator = MergeOperators::CreateStringAppendOperator(); options.merge_operator = MergeOperators::CreateStringAppendOperator();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
Statistics* stats = options.statistics.get(); Statistics* stats = options.statistics.get();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.index_type = table_options.index_type =
@ -2012,7 +2012,7 @@ TEST_P(DBIteratorTest, IterPrevKeyCrossingBlocksRandomized) {
TEST_P(DBIteratorTest, IteratorWithLocalStatistics) { TEST_P(DBIteratorTest, IteratorWithLocalStatistics) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
Random rnd(301); Random rnd(301);
@ -2110,7 +2110,7 @@ TEST_P(DBIteratorTest, ReadAhead) {
options.env = env_; options.env = env_;
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
options.write_buffer_size = 4 << 20; options.write_buffer_size = 4 << 20;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.block_size = 1024; table_options.block_size = 1024;
table_options.no_block_cache = true; table_options.no_block_cache = true;
@ -2188,7 +2188,7 @@ TEST_P(DBIteratorTest, DBIteratorSkipRecentDuplicatesTest) {
options.max_sequential_skip_in_iterations = 3; options.max_sequential_skip_in_iterations = 3;
options.prefix_extractor = nullptr; options.prefix_extractor = nullptr;
options.write_buffer_size = 1 << 27; // big enough to avoid flush options.write_buffer_size = 1 << 27; // big enough to avoid flush
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
// Insert. // Insert.
@ -2480,7 +2480,7 @@ TEST_P(DBIteratorTest, UpperBoundWithPrevReseek) {
TEST_P(DBIteratorTest, SkipStatistics) { TEST_P(DBIteratorTest, SkipStatistics) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
int skip_count = 0; int skip_count = 0;
@ -2989,10 +2989,10 @@ TEST_F(DBIteratorWithReadCallbackTest, ReadCallback) {
delete iter; delete iter;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -15,7 +15,7 @@
#include "db/db_test_util.h" #include "db/db_test_util.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTestXactLogIterator : public DBTestBase { class DBTestXactLogIterator : public DBTestBase {
public: public:
@ -98,14 +98,14 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorRace) {
for (int test = 0; test < LOG_ITERATOR_RACE_TEST_COUNT; ++test) { for (int test = 0; test < LOG_ITERATOR_RACE_TEST_COUNT; ++test) {
// Setup sync point dependency to reproduce the race condition of // Setup sync point dependency to reproduce the race condition of
// a log file moved to archived dir, in the middle of GetSortedWalFiles // a log file moved to archived dir, in the middle of GetSortedWalFiles
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{ { sync_points[test][0], sync_points[test][1] }, {sync_points[test][0], sync_points[test][1]},
{ sync_points[test][2], sync_points[test][3] }, {sync_points[test][2], sync_points[test][3]},
}); });
do { do {
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Options options = OptionsForLogIterTest(); Options options = OptionsForLogIterTest();
DestroyAndReopen(options); DestroyAndReopen(options);
Put("key1", DummyString(1024)); Put("key1", DummyString(1024));
@ -123,7 +123,7 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorRace) {
ExpectRecords(4, iter); ExpectRecords(4, iter);
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// trigger async flush, and log move. Well, log move will // trigger async flush, and log move. Well, log move will
// wait until the GetSortedWalFiles:1 to reproduce the race // wait until the GetSortedWalFiles:1 to reproduce the race
// condition // condition
@ -185,7 +185,7 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorCorruptedLog) {
dbfull()->Flush(FlushOptions()); dbfull()->Flush(FlushOptions());
dbfull()->FlushWAL(false); dbfull()->FlushWAL(false);
// Corrupt this log to create a gap // Corrupt this log to create a gap
rocksdb::VectorLogPtr wal_files; ROCKSDB_NAMESPACE::VectorLogPtr wal_files;
ASSERT_OK(dbfull()->GetSortedWalFiles(wal_files)); ASSERT_OK(dbfull()->GetSortedWalFiles(wal_files));
const auto logfile_path = dbname_ + "/" + wal_files.front()->PathName(); const auto logfile_path = dbname_ + "/" + wal_files.front()->PathName();
if (mem_env_) { if (mem_env_) {
@ -277,13 +277,13 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorBlobs) {
"Delete(0, key2)", "Delete(0, key2)",
handler.seen); handler.seen);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !defined(ROCKSDB_LITE) #endif // !defined(ROCKSDB_LITE)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else #else

View File

@ -13,7 +13,7 @@
#include "rocksdb/memtablerep.h" #include "rocksdb/memtablerep.h"
#include "rocksdb/slice_transform.h" #include "rocksdb/slice_transform.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBMemTableTest : public DBTestBase { class DBMemTableTest : public DBTestBase {
public: public:
@ -232,8 +232,8 @@ TEST_F(DBMemTableTest, ConcurrentMergeWrite) {
value.clear(); value.clear();
// Write Merge concurrently // Write Merge concurrently
rocksdb::port::Thread write_thread1([&]() { ROCKSDB_NAMESPACE::port::Thread write_thread1([&]() {
MemTablePostProcessInfo post_process_info1; MemTablePostProcessInfo post_process_info1;
std::string v1; std::string v1;
for (int seq = 1; seq < num_ops / 2; seq++) { for (int seq = 1; seq < num_ops / 2; seq++) {
PutFixed64(&v1, seq); PutFixed64(&v1, seq);
@ -243,8 +243,8 @@ TEST_F(DBMemTableTest, ConcurrentMergeWrite) {
v1.clear(); v1.clear();
} }
}); });
rocksdb::port::Thread write_thread2([&]() { ROCKSDB_NAMESPACE::port::Thread write_thread2([&]() {
MemTablePostProcessInfo post_process_info2; MemTablePostProcessInfo post_process_info2;
std::string v2; std::string v2;
for (int seq = num_ops / 2; seq < num_ops; seq++) { for (int seq = num_ops / 2; seq < num_ops; seq++) {
PutFixed64(&v2, seq); PutFixed64(&v2, seq);
@ -331,10 +331,10 @@ TEST_F(DBMemTableTest, ColumnFamilyId) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -17,7 +17,7 @@
#include "utilities/merge_operators/sortlist.h" #include "utilities/merge_operators/sortlist.h"
#include "utilities/merge_operators/string_append/stringappend2.h" #include "utilities/merge_operators/string_append/stringappend2.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBMergeOperandTest : public DBTestBase { class DBMergeOperandTest : public DBTestBase {
public: public:
@ -231,10 +231,10 @@ TEST_F(DBMergeOperandTest, GetMergeOperandsBasic) {
ASSERT_EQ(values[2], "am"); ASSERT_EQ(values[2], "am");
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -12,7 +12,7 @@
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
#include "utilities/merge_operators/string_append/stringappend2.h" #include "utilities/merge_operators/string_append/stringappend2.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class TestReadCallback : public ReadCallback { class TestReadCallback : public ReadCallback {
public: public:
@ -418,8 +418,8 @@ TEST_P(MergeOperatorPinningTest, TailingIterator) {
delete iter; delete iter;
}; };
rocksdb::port::Thread writer_thread(writer_func); ROCKSDB_NAMESPACE::port::Thread writer_thread(writer_func);
rocksdb::port::Thread reader_thread(reader_func); ROCKSDB_NAMESPACE::port::Thread reader_thread(reader_func);
writer_thread.join(); writer_thread.join();
reader_thread.join(); reader_thread.join();
@ -456,19 +456,19 @@ TEST_F(DBMergeOperatorTest, TailingIteratorMemtableUnrefedBySomeoneElse) {
bool pushed_first_operand = false; bool pushed_first_operand = false;
bool stepped_to_next_operand = false; bool stepped_to_next_operand = false;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBIter::MergeValuesNewToOld:PushedFirstOperand", [&](void*) { "DBIter::MergeValuesNewToOld:PushedFirstOperand", [&](void*) {
EXPECT_FALSE(pushed_first_operand); EXPECT_FALSE(pushed_first_operand);
pushed_first_operand = true; pushed_first_operand = true;
db_->Flush(FlushOptions()); // Switch to SuperVersion B db_->Flush(FlushOptions()); // Switch to SuperVersion B
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBIter::MergeValuesNewToOld:SteppedToNextOperand", [&](void*) { "DBIter::MergeValuesNewToOld:SteppedToNextOperand", [&](void*) {
EXPECT_FALSE(stepped_to_next_operand); EXPECT_FALSE(stepped_to_next_operand);
stepped_to_next_operand = true; stepped_to_next_operand = true;
someone_else.reset(); // Unpin SuperVersion A someone_else.reset(); // Unpin SuperVersion A
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ReadOptions ro; ReadOptions ro;
ro.tailing = true; ro.tailing = true;
@ -657,10 +657,10 @@ TEST_P(PerConfigMergeOperatorPinningTest, Randomized) {
VerifyDBFromMap(true_data); VerifyDBFromMap(true_data);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -23,7 +23,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "util/random.h" #include "util/random.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBOptionsTest : public DBTestBase { class DBOptionsTest : public DBTestBase {
public: public:
@ -134,19 +134,17 @@ TEST_F(DBOptionsTest, SetBytesPerSync) {
int i = 0; int i = 0;
const std::string kValue(kValueSize, 'v'); const std::string kValue(kValueSize, 'v');
ASSERT_EQ(options.bytes_per_sync, dbfull()->GetDBOptions().bytes_per_sync); ASSERT_EQ(options.bytes_per_sync, dbfull()->GetDBOptions().bytes_per_sync);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { "WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { counter++; });
counter++;
});
WriteOptions write_opts; WriteOptions write_opts;
// should sync approximately 40MB/1MB ~= 40 times. // should sync approximately 40MB/1MB ~= 40 times.
for (i = 0; i < 40; i++) { for (i = 0; i < 40; i++) {
Put(Key(i), kValue, write_opts); Put(Key(i), kValue, write_opts);
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr)); ASSERT_OK(dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
low_bytes_per_sync = counter; low_bytes_per_sync = counter;
ASSERT_GT(low_bytes_per_sync, 35); ASSERT_GT(low_bytes_per_sync, 35);
ASSERT_LT(low_bytes_per_sync, 45); ASSERT_LT(low_bytes_per_sync, 45);
@ -160,7 +158,7 @@ TEST_F(DBOptionsTest, SetBytesPerSync) {
for (i = 0; i < 40; i++) { for (i = 0; i < 40; i++) {
Put(Key(i), kValue, write_opts); Put(Key(i), kValue, write_opts);
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr)); ASSERT_OK(dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr));
ASSERT_GT(counter, 5); ASSERT_GT(counter, 5);
ASSERT_LT(counter, 15); ASSERT_LT(counter, 15);
@ -183,11 +181,9 @@ TEST_F(DBOptionsTest, SetWalBytesPerSync) {
ASSERT_EQ(512, dbfull()->GetDBOptions().wal_bytes_per_sync); ASSERT_EQ(512, dbfull()->GetDBOptions().wal_bytes_per_sync);
int counter = 0; int counter = 0;
int low_bytes_per_sync = 0; int low_bytes_per_sync = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { "WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { counter++; });
counter++; ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
const std::string kValue(kValueSize, 'v'); const std::string kValue(kValueSize, 'v');
int i = 0; int i = 0;
for (; i < 10; i++) { for (; i < 10; i++) {
@ -223,7 +219,7 @@ TEST_F(DBOptionsTest, WritableFileMaxBufferSize) {
std::atomic<int> match_cnt(0); std::atomic<int> match_cnt(0);
std::atomic<int> unmatch_cnt(0); std::atomic<int> unmatch_cnt(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::WritableFileWriter:0", [&](void* arg) { "WritableFileWriter::WritableFileWriter:0", [&](void* arg) {
int value = static_cast<int>(reinterpret_cast<uintptr_t>(arg)); int value = static_cast<int>(reinterpret_cast<uintptr_t>(arg));
if (value == buffer_size) { if (value == buffer_size) {
@ -232,7 +228,7 @@ TEST_F(DBOptionsTest, WritableFileMaxBufferSize) {
unmatch_cnt++; unmatch_cnt++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
int i = 0; int i = 0;
for (; i < 3; i++) { for (; i < 3; i++) {
ASSERT_OK(Put("foo", ToString(i))); ASSERT_OK(Put("foo", ToString(i)));
@ -865,10 +861,10 @@ TEST_F(DBOptionsTest, FIFOTtlBackwardCompatible) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -22,7 +22,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBPropertiesTest : public DBTestBase { class DBPropertiesTest : public DBTestBase {
public: public:
@ -391,16 +391,16 @@ TEST_F(DBPropertiesTest, ReadLatencyHistogramByLevel) {
options.max_bytes_for_level_base = 4500 << 10; options.max_bytes_for_level_base = 4500 << 10;
options.target_file_size_base = 98 << 10; options.target_file_size_base = 98 << 10;
options.max_write_buffer_number = 2; options.max_write_buffer_number = 2;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.max_open_files = 11; // Make sure no proloading of table readers options.max_open_files = 11; // Make sure no proloading of table readers
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = 11; *max_open_files = 11;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.no_block_cache = true; table_options.no_block_cache = true;
@ -448,7 +448,7 @@ TEST_F(DBPropertiesTest, ReadLatencyHistogramByLevel) {
// Reopen and issue iterating. See thee latency tracked // Reopen and issue iterating. See thee latency tracked
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_TRUE(dbfull()->GetProperty("rocksdb.cf-file-histogram", &prop)); ASSERT_TRUE(dbfull()->GetProperty("rocksdb.cf-file-histogram", &prop));
ASSERT_EQ(std::string::npos, prop.find("** Level 0 read latency histogram")); ASSERT_EQ(std::string::npos, prop.find("** Level 0 read latency histogram"));
ASSERT_EQ(std::string::npos, prop.find("** Level 1 read latency histogram")); ASSERT_EQ(std::string::npos, prop.find("** Level 1 read latency histogram"));
@ -1702,10 +1702,10 @@ TEST_F(DBPropertiesTest, BlockCacheProperties) {
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -9,7 +9,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBRangeDelTest : public DBTestBase { class DBRangeDelTest : public DBTestBase {
public: public:
@ -925,7 +925,8 @@ TEST_F(DBRangeDelTest, MemtableBloomFilter) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.memtable_prefix_bloom_size_ratio = options.memtable_prefix_bloom_size_ratio =
static_cast<double>(kMemtablePrefixFilterSize) / kMemtableSize; static_cast<double>(kMemtablePrefixFilterSize) / kMemtableSize;
options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(kPrefixLen)); options.prefix_extractor.reset(
ROCKSDB_NAMESPACE::NewFixedPrefixTransform(kPrefixLen));
options.write_buffer_size = kMemtableSize; options.write_buffer_size = kMemtableSize;
Reopen(options); Reopen(options);
@ -1078,7 +1079,7 @@ TEST_F(DBRangeDelTest, RangeTombstoneEndKeyAsSstableUpperBound) {
// endpoint (key000002#6,1) to disappear. // endpoint (key000002#6,1) to disappear.
ASSERT_EQ(value, Get(Key(2))); ASSERT_EQ(value, Get(Key(2)));
auto begin_str = Key(3); auto begin_str = Key(3);
const rocksdb::Slice begin = begin_str; const ROCKSDB_NAMESPACE::Slice begin = begin_str;
dbfull()->TEST_CompactRange(1, &begin, nullptr); dbfull()->TEST_CompactRange(1, &begin, nullptr);
ASSERT_EQ(1, NumTableFilesAtLevel(1)); ASSERT_EQ(1, NumTableFilesAtLevel(1));
ASSERT_EQ(2, NumTableFilesAtLevel(2)); ASSERT_EQ(2, NumTableFilesAtLevel(2));
@ -1097,7 +1098,7 @@ TEST_F(DBRangeDelTest, RangeTombstoneEndKeyAsSstableUpperBound) {
// [key000001#5,1, key000002#72057594037927935,15] // [key000001#5,1, key000002#72057594037927935,15]
// [key000002#6,1, key000004#72057594037927935,15] // [key000002#6,1, key000004#72057594037927935,15]
auto begin_str = Key(0); auto begin_str = Key(0);
const rocksdb::Slice begin = begin_str; const ROCKSDB_NAMESPACE::Slice begin = begin_str;
dbfull()->TEST_CompactRange(1, &begin, &begin); dbfull()->TEST_CompactRange(1, &begin, &begin);
ASSERT_EQ(0, NumTableFilesAtLevel(1)); ASSERT_EQ(0, NumTableFilesAtLevel(1));
ASSERT_EQ(3, NumTableFilesAtLevel(2)); ASSERT_EQ(3, NumTableFilesAtLevel(2));
@ -1650,10 +1651,10 @@ TEST_F(DBRangeDelTest, OverlappedKeys) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -13,7 +13,7 @@
#include "port/stack_trace.h" #include "port/stack_trace.h"
#include "rocksdb/sst_file_manager.h" #include "rocksdb/sst_file_manager.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBSSTTest : public DBTestBase { class DBSSTTest : public DBTestBase {
public: public:
@ -283,13 +283,14 @@ TEST_F(DBSSTTest, DBWithSstFileManager) {
int files_added = 0; int files_added = 0;
int files_deleted = 0; int files_deleted = 0;
int files_moved = 0; int files_moved = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnAddFile", [&](void* /*arg*/) { files_added++; }); "SstFileManagerImpl::OnAddFile", [&](void* /*arg*/) { files_added++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnDeleteFile", [&](void* /*arg*/) { files_deleted++; }); "SstFileManagerImpl::OnDeleteFile",
rocksdb::SyncPoint::GetInstance()->SetCallBack( [&](void* /*arg*/) { files_deleted++; });
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnMoveFile", [&](void* /*arg*/) { files_moved++; }); "SstFileManagerImpl::OnMoveFile", [&](void* /*arg*/) { files_moved++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.sst_file_manager = sst_file_manager; options.sst_file_manager = sst_file_manager;
@ -337,21 +338,21 @@ TEST_F(DBSSTTest, DBWithSstFileManager) {
ASSERT_EQ(sfm->GetTrackedFiles(), files_in_db); ASSERT_EQ(sfm->GetTrackedFiles(), files_in_db);
ASSERT_EQ(sfm->GetTotalSize(), total_files_size); ASSERT_EQ(sfm->GetTotalSize(), total_files_size);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBSSTTest, RateLimitedDelete) { TEST_F(DBSSTTest, RateLimitedDelete) {
Destroy(last_options_); Destroy(last_options_);
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBSSTTest::RateLimitedDelete:1", {"DBSSTTest::RateLimitedDelete:1",
"DeleteScheduler::BackgroundEmptyTrash"}, "DeleteScheduler::BackgroundEmptyTrash"},
}); });
std::vector<uint64_t> penalties; std::vector<uint64_t> penalties;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::BackgroundEmptyTrash:Wait", "DeleteScheduler::BackgroundEmptyTrash:Wait",
[&](void* arg) { penalties.push_back(*(static_cast<uint64_t*>(arg))); }); [&](void* arg) { penalties.push_back(*(static_cast<uint64_t*>(arg))); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"InstrumentedCondVar::TimedWaitInternal", [&](void* arg) { "InstrumentedCondVar::TimedWaitInternal", [&](void* arg) {
// Turn timed wait into a simulated sleep // Turn timed wait into a simulated sleep
uint64_t* abs_time_us = static_cast<uint64_t*>(arg); uint64_t* abs_time_us = static_cast<uint64_t*>(arg);
@ -372,7 +373,7 @@ TEST_F(DBSSTTest, RateLimitedDelete) {
*abs_time_us = static_cast<uint64_t>(real_cur_time); *abs_time_us = static_cast<uint64_t>(real_cur_time);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
env_->no_slowdown_ = true; env_->no_slowdown_ = true;
env_->time_elapse_only_sleep_ = true; env_->time_elapse_only_sleep_ = true;
@ -437,14 +438,14 @@ TEST_F(DBSSTTest, RateLimitedDelete) {
ASSERT_GT(time_spent_deleting, expected_penlty * 0.9); ASSERT_GT(time_spent_deleting, expected_penlty * 0.9);
ASSERT_LT(time_spent_deleting, expected_penlty * 1.1); ASSERT_LT(time_spent_deleting, expected_penlty * 1.1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBSSTTest, RateLimitedWALDelete) { TEST_F(DBSSTTest, RateLimitedWALDelete) {
Destroy(last_options_); Destroy(last_options_);
std::vector<uint64_t> penalties; std::vector<uint64_t> penalties;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::BackgroundEmptyTrash:Wait", "DeleteScheduler::BackgroundEmptyTrash:Wait",
[&](void* arg) { penalties.push_back(*(static_cast<uint64_t*>(arg))); }); [&](void* arg) { penalties.push_back(*(static_cast<uint64_t*>(arg))); });
@ -465,7 +466,7 @@ TEST_F(DBSSTTest, RateLimitedWALDelete) {
sfm->delete_scheduler()->SetMaxTrashDBRatio(3.1); sfm->delete_scheduler()->SetMaxTrashDBRatio(3.1);
ASSERT_OK(TryReopen(options)); ASSERT_OK(TryReopen(options));
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Create 4 files in L0 // Create 4 files in L0
for (char v = 'a'; v <= 'd'; v++) { for (char v = 'a'; v <= 'd'; v++) {
@ -489,7 +490,7 @@ TEST_F(DBSSTTest, RateLimitedWALDelete) {
sfm->WaitForEmptyTrash(); sfm->WaitForEmptyTrash();
ASSERT_EQ(penalties.size(), 8); ASSERT_EQ(penalties.size(), 8);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
class DBWALTestWithParam class DBWALTestWithParam
@ -627,14 +628,13 @@ TEST_F(DBSSTTest, OpenDBWithExistingTrash) {
// files in the second path were not. // files in the second path were not.
TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) { TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
std::atomic<int> bg_delete_file(0); std::atomic<int> bg_delete_file(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteTrashFile:DeleteFile", "DeleteScheduler::DeleteTrashFile:DeleteFile",
[&](void* /*arg*/) { bg_delete_file++; }); [&](void* /*arg*/) { bg_delete_file++; });
// The deletion scheduler sometimes skips marking file as trash according to // The deletion scheduler sometimes skips marking file as trash according to
// a heuristic. In that case the deletion will go through the below SyncPoint. // a heuristic. In that case the deletion will go through the below SyncPoint.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteFile", "DeleteScheduler::DeleteFile", [&](void* /*arg*/) { bg_delete_file++; });
[&](void* /*arg*/) { bg_delete_file++; });
Options options = CurrentOptions(); Options options = CurrentOptions();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
@ -652,7 +652,7 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
auto sfm = static_cast<SstFileManagerImpl*>(options.sst_file_manager.get()); auto sfm = static_cast<SstFileManagerImpl*>(options.sst_file_manager.get());
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.disableWAL = true; wo.disableWAL = true;
@ -700,15 +700,15 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
sfm->WaitForEmptyTrash(); sfm->WaitForEmptyTrash();
ASSERT_EQ(bg_delete_file, 10); ASSERT_EQ(bg_delete_file, 10);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) { TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) {
int bg_delete_file = 0; int bg_delete_file = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteTrashFile:DeleteFile", "DeleteScheduler::DeleteTrashFile:DeleteFile",
[&](void* /*arg*/) { bg_delete_file++; }); [&](void* /*arg*/) { bg_delete_file++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Status s; Status s;
Options options = CurrentOptions(); Options options = CurrentOptions();
@ -793,15 +793,15 @@ TEST_F(DBSSTTest, CancellingCompactionsWorks) {
DestroyAndReopen(options); DestroyAndReopen(options);
int completed_compactions = 0; int completed_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* /*arg*/) {
sfm->SetMaxAllowedSpaceUsage(0); sfm->SetMaxAllowedSpaceUsage(0);
ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0); ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0);
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", "DBImpl::BackgroundCompaction:NonTrivial:AfterRun",
[&](void* /*arg*/) { completed_compactions++; }); [&](void* /*arg*/) { completed_compactions++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
@ -828,7 +828,7 @@ TEST_F(DBSSTTest, CancellingCompactionsWorks) {
ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0); ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0);
// Make sure the stat is bumped // Make sure the stat is bumped
ASSERT_GT(dbfull()->immutable_db_options().statistics.get()->getTickerCount(COMPACTION_CANCELLED), 0); ASSERT_GT(dbfull()->immutable_db_options().statistics.get()->getTickerCount(COMPACTION_CANCELLED), 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBSSTTest, CancellingManualCompactionsWorks) { TEST_F(DBSSTTest, CancellingManualCompactionsWorks) {
@ -876,7 +876,7 @@ TEST_F(DBSSTTest, CancellingManualCompactionsWorks) {
// Now make sure CompactFiles also gets cancelled // Now make sure CompactFiles also gets cancelled
auto l0_files = collector->GetFlushedFiles(); auto l0_files = collector->GetFlushedFiles();
dbfull()->CompactFiles(rocksdb::CompactionOptions(), l0_files, 0); dbfull()->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(), l0_files, 0);
// Wait for manual compaction to get scheduled and finish // Wait for manual compaction to get scheduled and finish
dbfull()->TEST_WaitForCompact(true); dbfull()->TEST_WaitForCompact(true);
@ -890,17 +890,17 @@ TEST_F(DBSSTTest, CancellingManualCompactionsWorks) {
// returns to normal // returns to normal
sfm->SetMaxAllowedSpaceUsage(0); sfm->SetMaxAllowedSpaceUsage(0);
int completed_compactions = 0; int completed_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactFilesImpl:End", [&](void* /*arg*/) { completed_compactions++; }); "CompactFilesImpl:End", [&](void* /*arg*/) { completed_compactions++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->CompactFiles(rocksdb::CompactionOptions(), l0_files, 0); dbfull()->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(), l0_files, 0);
dbfull()->TEST_WaitForCompact(true); dbfull()->TEST_WaitForCompact(true);
ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0); ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0);
ASSERT_GT(completed_compactions, 0); ASSERT_GT(completed_compactions, 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) { TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
@ -914,7 +914,7 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
std::atomic<int> reached_max_space_on_flush(0); std::atomic<int> reached_max_space_on_flush(0);
std::atomic<int> reached_max_space_on_compaction(0); std::atomic<int> reached_max_space_on_compaction(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached", "DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached",
[&](void* arg) { [&](void* arg) {
Status* bg_error = static_cast<Status*>(arg); Status* bg_error = static_cast<Status*>(arg);
@ -924,13 +924,13 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
*bg_error = Status::OK(); *bg_error = Status::OK();
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* arg) { "DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* arg) {
bool* enough_room = static_cast<bool*>(arg); bool* enough_room = static_cast<bool*>(arg);
*enough_room = true; *enough_room = true;
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::FinishCompactionOutputFile:MaxAllowedSpaceReached", "CompactionJob::FinishCompactionOutputFile:MaxAllowedSpaceReached",
[&](void* /*arg*/) { [&](void* /*arg*/) {
bg_error_set = true; bg_error_set = true;
@ -939,8 +939,8 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
for (auto limit_mb : max_space_limits_mbs) { for (auto limit_mb : max_space_limits_mbs) {
bg_error_set = false; bg_error_set = false;
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_)); std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
auto sfm = static_cast<SstFileManagerImpl*>(sst_file_manager.get()); auto sfm = static_cast<SstFileManagerImpl*>(sst_file_manager.get());
@ -964,7 +964,7 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
uint64_t total_sst_files_size = 0; uint64_t total_sst_files_size = 0;
GetAllSSTFiles(&total_sst_files_size); GetAllSSTFiles(&total_sst_files_size);
ASSERT_GE(total_sst_files_size, limit_mb * 1024 * 1024); ASSERT_GE(total_sst_files_size, limit_mb * 1024 * 1024);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
ASSERT_GT(reached_max_space_on_flush, 0); ASSERT_GT(reached_max_space_on_flush, 0);
@ -1218,10 +1218,10 @@ TEST_F(DBSSTTest, GetTotalSstFilesSizeVersionsFilesShared) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -10,7 +10,7 @@
#include "port/stack_trace.h" #include "port/stack_trace.h"
#include "rocksdb/statistics.h" #include "rocksdb/statistics.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBStatisticsTest : public DBTestBase { class DBStatisticsTest : public DBTestBase {
public: public:
@ -45,7 +45,7 @@ TEST_F(DBStatisticsTest, CompressionStatsTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compression = type; options.compression = type;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.statistics->set_stats_level(StatsLevel::kExceptTimeForMutex); options.statistics->set_stats_level(StatsLevel::kExceptTimeForMutex);
DestroyAndReopen(options); DestroyAndReopen(options);
@ -91,7 +91,7 @@ TEST_F(DBStatisticsTest, CompressionStatsTest) {
TEST_F(DBStatisticsTest, MutexWaitStatsDisabledByDefault) { TEST_F(DBStatisticsTest, MutexWaitStatsDisabledByDefault) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
const uint64_t kMutexWaitDelay = 100; const uint64_t kMutexWaitDelay = 100;
ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT, ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT,
@ -104,7 +104,7 @@ TEST_F(DBStatisticsTest, MutexWaitStatsDisabledByDefault) {
TEST_F(DBStatisticsTest, MutexWaitStats) { TEST_F(DBStatisticsTest, MutexWaitStats) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.statistics->set_stats_level(StatsLevel::kAll); options.statistics->set_stats_level(StatsLevel::kAll);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
const uint64_t kMutexWaitDelay = 100; const uint64_t kMutexWaitDelay = 100;
@ -118,7 +118,7 @@ TEST_F(DBStatisticsTest, MutexWaitStats) {
TEST_F(DBStatisticsTest, ResetStats) { TEST_F(DBStatisticsTest, ResetStats) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
// pick arbitrary ticker and histogram. On first iteration they're zero // pick arbitrary ticker and histogram. On first iteration they're zero
@ -140,10 +140,10 @@ TEST_F(DBStatisticsTest, ResetStats) {
} }
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -19,7 +19,7 @@
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// A helper function that ensures the table properties returned in // A helper function that ensures the table properties returned in
// `GetPropertiesOfAllTablesTest` is correct. // `GetPropertiesOfAllTablesTest` is correct.
@ -325,12 +325,12 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) {
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -16,7 +16,7 @@
#include "db/forward_iterator.h" #include "db/forward_iterator.h"
#include "port/stack_trace.h" #include "port/stack_trace.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTestTailingIterator : public DBTestBase { class DBTestTailingIterator : public DBTestBase {
public: public:
@ -98,8 +98,8 @@ TEST_F(DBTestTailingIterator, TailingIteratorSeekToNext) {
ASSERT_TRUE(itern->Valid()); ASSERT_TRUE(itern->Valid());
ASSERT_EQ(itern->key().compare(key), 0); ASSERT_EQ(itern->key().compare(key), 0);
} }
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
for (int i = 2 * num_records; i > 0; --i) { for (int i = 2 * num_records; i > 0; --i) {
char buf1[32]; char buf1[32];
char buf2[32]; char buf2[32];
@ -143,25 +143,25 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
bool file_iters_deleted = false; bool file_iters_deleted = false;
bool file_iters_renewed_null = false; bool file_iters_renewed_null = false;
bool file_iters_renewed_copy = false; bool file_iters_renewed_copy = false;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::SeekInternal:Return", [&](void* arg) { "ForwardIterator::SeekInternal:Return", [&](void* arg) {
ForwardIterator* fiter = reinterpret_cast<ForwardIterator*>(arg); ForwardIterator* fiter = reinterpret_cast<ForwardIterator*>(arg);
ASSERT_TRUE(!file_iters_deleted || ASSERT_TRUE(!file_iters_deleted ||
fiter->TEST_CheckDeletedIters(&deleted_iters, &num_iters)); fiter->TEST_CheckDeletedIters(&deleted_iters, &num_iters));
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::Next:Return", [&](void* arg) { "ForwardIterator::Next:Return", [&](void* arg) {
ForwardIterator* fiter = reinterpret_cast<ForwardIterator*>(arg); ForwardIterator* fiter = reinterpret_cast<ForwardIterator*>(arg);
ASSERT_TRUE(!file_iters_deleted || ASSERT_TRUE(!file_iters_deleted ||
fiter->TEST_CheckDeletedIters(&deleted_iters, &num_iters)); fiter->TEST_CheckDeletedIters(&deleted_iters, &num_iters));
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::RenewIterators:Null", "ForwardIterator::RenewIterators:Null",
[&](void* /*arg*/) { file_iters_renewed_null = true; }); [&](void* /*arg*/) { file_iters_renewed_null = true; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::RenewIterators:Copy", "ForwardIterator::RenewIterators:Copy",
[&](void* /*arg*/) { file_iters_renewed_copy = true; }); [&](void* /*arg*/) { file_iters_renewed_copy = true; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
const int num_records = 1000; const int num_records = 1000;
for (int i = 1; i < num_records; ++i) { for (int i = 1; i < num_records; ++i) {
char buf1[32]; char buf1[32];
@ -413,14 +413,14 @@ TEST_F(DBTestTailingIterator, TailingIteratorUpperBound) {
// This keeps track of the number of times NeedToSeekImmutable() was true. // This keeps track of the number of times NeedToSeekImmutable() was true.
int immutable_seeks = 0; int immutable_seeks = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::SeekInternal:Immutable", "ForwardIterator::SeekInternal:Immutable",
[&](void* /*arg*/) { ++immutable_seeks; }); [&](void* /*arg*/) { ++immutable_seeks; });
// Seek to 13. This should not require any immutable seeks. // Seek to 13. This should not require any immutable seeks.
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
it->Seek("13"); it->Seek("13");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_FALSE(it->Valid()); ASSERT_FALSE(it->Valid());
ASSERT_EQ(0, immutable_seeks); ASSERT_EQ(0, immutable_seeks);
@ -530,13 +530,13 @@ TEST_F(DBTestTailingIterator, SeekToFirstWithUpperBoundBug) {
ASSERT_EQ(iter->key().ToString(), "aa"); ASSERT_EQ(iter->key().ToString(), "aa");
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !defined(ROCKSDB_LITE) #endif // !defined(ROCKSDB_LITE)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else #else

View File

@ -68,7 +68,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTest : public DBTestBase { class DBTest : public DBTestBase {
public: public:
@ -232,14 +232,14 @@ TEST_F(DBTest, SkipDelay) {
// the test flaky // the test flaky
auto token = dbfull()->TEST_write_controler().GetDelayToken(1); auto token = dbfull()->TEST_write_controler().GetDelayToken(1);
std::atomic<int> sleep_count(0); std::atomic<int> sleep_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Sleep", "DBImpl::DelayWrite:Sleep",
[&](void* /*arg*/) { sleep_count.fetch_add(1); }); [&](void* /*arg*/) { sleep_count.fetch_add(1); });
std::atomic<int> wait_count(0); std::atomic<int> wait_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait", "DBImpl::DelayWrite:Wait",
[&](void* /*arg*/) { wait_count.fetch_add(1); }); [&](void* /*arg*/) { wait_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = sync; wo.sync = sync;
@ -290,9 +290,8 @@ TEST_F(DBTest, MixedSlowdownOptions) {
// the test flaky // the test flaky
auto token = dbfull()->TEST_write_controler().GetDelayToken(1); auto token = dbfull()->TEST_write_controler().GetDelayToken(1);
std::atomic<int> sleep_count(0); std::atomic<int> sleep_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:BeginWriteStallDone", "DBImpl::DelayWrite:BeginWriteStallDone", [&](void* /*arg*/) {
[&](void* /*arg*/) {
sleep_count.fetch_add(1); sleep_count.fetch_add(1);
if (threads.empty()) { if (threads.empty()) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
@ -303,7 +302,7 @@ TEST_F(DBTest, MixedSlowdownOptions) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = false; wo.sync = false;
@ -345,9 +344,8 @@ TEST_F(DBTest, MixedSlowdownOptionsInQueue) {
// the test flaky // the test flaky
auto token = dbfull()->TEST_write_controler().GetDelayToken(1); auto token = dbfull()->TEST_write_controler().GetDelayToken(1);
std::atomic<int> sleep_count(0); std::atomic<int> sleep_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Sleep", "DBImpl::DelayWrite:Sleep", [&](void* /*arg*/) {
[&](void* /*arg*/) {
sleep_count.fetch_add(1); sleep_count.fetch_add(1);
if (threads.empty()) { if (threads.empty()) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
@ -359,10 +357,10 @@ TEST_F(DBTest, MixedSlowdownOptionsInQueue) {
} }
}); });
std::atomic<int> wait_count(0); std::atomic<int> wait_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait", "DBImpl::DelayWrite:Wait",
[&](void* /*arg*/) { wait_count.fetch_add(1); }); [&](void* /*arg*/) { wait_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = false; wo.sync = false;
@ -414,9 +412,8 @@ TEST_F(DBTest, MixedSlowdownOptionsStop) {
// the test flaky // the test flaky
auto token = dbfull()->TEST_write_controler().GetStopToken(); auto token = dbfull()->TEST_write_controler().GetStopToken();
std::atomic<int> wait_count(0); std::atomic<int> wait_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait", "DBImpl::DelayWrite:Wait", [&](void* /*arg*/) {
[&](void* /*arg*/) {
wait_count.fetch_add(1); wait_count.fetch_add(1);
if (threads.empty()) { if (threads.empty()) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
@ -432,7 +429,7 @@ TEST_F(DBTest, MixedSlowdownOptionsStop) {
token.reset(); token.reset();
threads.emplace_back(wakeup_writer); threads.emplace_back(wakeup_writer);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
wo.sync = false; wo.sync = false;
@ -2592,15 +2589,15 @@ TEST_F(DBTest, GroupCommitTest) {
do { do {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.env = env_; options.env = env_;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
Reopen(options); Reopen(options);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"WriteThread::JoinBatchGroup:BeganWaiting", {{"WriteThread::JoinBatchGroup:BeganWaiting",
"DBImpl::WriteImpl:BeforeLeaderEnters"}, "DBImpl::WriteImpl:BeforeLeaderEnters"},
{"WriteThread::AwaitState:BlockingWaiting", {"WriteThread::AwaitState:BlockingWaiting",
"WriteThread::EnterAsBatchGroupLeader:End"}}); "WriteThread::EnterAsBatchGroupLeader:End"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Start threads // Start threads
GCThread thread[kGCNumThreads]; GCThread thread[kGCNumThreads];
@ -2919,13 +2916,13 @@ class ModelDB : public DB {
DBOptions GetDBOptions() const override { return options_; } DBOptions GetDBOptions() const override { return options_; }
using DB::Flush; using DB::Flush;
Status Flush(const rocksdb::FlushOptions& /*options*/, Status Flush(const ROCKSDB_NAMESPACE::FlushOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/) override { ColumnFamilyHandle* /*column_family*/) override {
Status ret; Status ret;
return ret; return ret;
} }
Status Flush( Status Flush(
const rocksdb::FlushOptions& /*options*/, const ROCKSDB_NAMESPACE::FlushOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override { const std::vector<ColumnFamilyHandle*>& /*column_families*/) override {
return Status::OK(); return Status::OK();
} }
@ -2958,8 +2955,8 @@ class ModelDB : public DB {
Status DeleteFile(std::string /*name*/) override { return Status::OK(); } Status DeleteFile(std::string /*name*/) override { return Status::OK(); }
Status GetUpdatesSince( Status GetUpdatesSince(
rocksdb::SequenceNumber, ROCKSDB_NAMESPACE::SequenceNumber,
std::unique_ptr<rocksdb::TransactionLogIterator>*, std::unique_ptr<ROCKSDB_NAMESPACE::TransactionLogIterator>*,
const TransactionLogIterator::ReadOptions& /*read_options*/ = const TransactionLogIterator::ReadOptions& /*read_options*/ =
TransactionLogIterator::ReadOptions()) override { TransactionLogIterator::ReadOptions()) override {
return Status::NotSupported("Not supported in Model DB"); return Status::NotSupported("Not supported in Model DB");
@ -3219,12 +3216,12 @@ TEST_F(DBTest, BlockBasedTablePrefixIndexTotalOrderSeek) {
options.prefix_extractor.reset(NewFixedPrefixTransform(1)); options.prefix_extractor.reset(NewFixedPrefixTransform(1));
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = 11; *max_open_files = 11;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Reopen(options); Reopen(options);
ASSERT_OK(Put("k1", "v1")); ASSERT_OK(Put("k1", "v1"));
@ -3257,7 +3254,7 @@ TEST_F(DBTest, BlockBasedTablePrefixIndexTotalOrderSeek) {
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
ASSERT_EQ("k1", iter->key().ToString()); ASSERT_EQ("k1", iter->key().ToString());
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest, ChecksumTest) { TEST_F(DBTest, ChecksumTest) {
@ -3681,7 +3678,7 @@ TEST_F(DBTest, DISABLED_RateLimitingTest) {
options.compression = kNoCompression; options.compression = kNoCompression;
options.create_if_missing = true; options.create_if_missing = true;
options.env = env_; options.env = env_;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.IncreaseParallelism(4); options.IncreaseParallelism(4);
DestroyAndReopen(options); DestroyAndReopen(options);
@ -4007,10 +4004,10 @@ TEST_F(DBTest, DynamicMemtableOptions) {
int count = 0; int count = 0;
Random rnd(301); Random rnd(301);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait", "DBImpl::DelayWrite:Wait",
[&](void* /*arg*/) { sleeping_task_low.WakeUp(); }); [&](void* /*arg*/) { sleeping_task_low.WakeUp(); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
while (!sleeping_task_low.WokenUp() && count < 256) { while (!sleeping_task_low.WokenUp() && count < 256) {
ASSERT_OK(Put(Key(count), RandomString(&rnd, 1024), WriteOptions())); ASSERT_OK(Put(Key(count), RandomString(&rnd, 1024), WriteOptions()));
@ -4068,7 +4065,7 @@ TEST_F(DBTest, DynamicMemtableOptions) {
#endif #endif
sleeping_task_low.WaitUntilDone(); sleeping_task_low.WaitUntilDone();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -4177,11 +4174,11 @@ TEST_F(DBTest, ThreadStatusFlush) {
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
options = CurrentOptions(options); options = CurrentOptions(options);
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"FlushJob::FlushJob()", "DBTest::ThreadStatusFlush:1"}, {"FlushJob::FlushJob()", "DBTest::ThreadStatusFlush:1"},
{"DBTest::ThreadStatusFlush:2", "FlushJob::WriteLevel0Table"}, {"DBTest::ThreadStatusFlush:2", "FlushJob::WriteLevel0Table"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
VerifyOperationCount(env_, ThreadStatus::OP_FLUSH, 0); VerifyOperationCount(env_, ThreadStatus::OP_FLUSH, 0);
@ -4206,7 +4203,7 @@ TEST_F(DBTest, ThreadStatusFlush) {
// This second sync point is to ensure the flush job will not // This second sync point is to ensure the flush job will not
// be completed until we already perform VerifyOperationCount(). // be completed until we already perform VerifyOperationCount().
TEST_SYNC_POINT("DBTest::ThreadStatusFlush:2"); TEST_SYNC_POINT("DBTest::ThreadStatusFlush:2");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) { TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
@ -4229,15 +4226,15 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
options.level0_file_num_compaction_trigger = kNumL0Files; options.level0_file_num_compaction_trigger = kNumL0Files;
options.max_subcompactions = max_subcompactions_; options.max_subcompactions = max_subcompactions_;
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBTest::ThreadStatusSingleCompaction:0", "DBImpl::BGWorkCompaction"}, {"DBTest::ThreadStatusSingleCompaction:0", "DBImpl::BGWorkCompaction"},
{"CompactionJob::Run():Start", "DBTest::ThreadStatusSingleCompaction:1"}, {"CompactionJob::Run():Start", "DBTest::ThreadStatusSingleCompaction:1"},
{"DBTest::ThreadStatusSingleCompaction:2", "CompactionJob::Run():End"}, {"DBTest::ThreadStatusSingleCompaction:2", "CompactionJob::Run():End"},
}); });
for (int tests = 0; tests < 2; ++tests) { for (int tests = 0; tests < 2; ++tests) {
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
// The Put Phase. // The Put Phase.
@ -4276,7 +4273,7 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
// repeat the test with disabling thread tracking. // repeat the test with disabling thread tracking.
options.enable_thread_tracking = false; options.enable_thread_tracking = false;
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -4373,7 +4370,7 @@ TEST_P(DBTestWithParam, PreShutdownMultipleCompaction) {
std::vector<ThreadStatus> thread_list; std::vector<ThreadStatus> thread_list;
// Delay both flush and compaction // Delay both flush and compaction
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"FlushJob::FlushJob()", "CompactionJob::Run():Start"}, {{"FlushJob::FlushJob()", "CompactionJob::Run():Start"},
{"CompactionJob::Run():Start", {"CompactionJob::Run():Start",
"DBTest::PreShutdownMultipleCompaction:Preshutdown"}, "DBTest::PreShutdownMultipleCompaction:Preshutdown"},
@ -4384,7 +4381,7 @@ TEST_P(DBTestWithParam, PreShutdownMultipleCompaction) {
{"CompactionJob::Run():End", {"CompactionJob::Run():End",
"DBTest::PreShutdownMultipleCompaction:VerifyPreshutdown"}}); "DBTest::PreShutdownMultipleCompaction:VerifyPreshutdown"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Make rocksdb busy // Make rocksdb busy
int key = 0; int key = 0;
@ -4462,7 +4459,7 @@ TEST_P(DBTestWithParam, PreShutdownCompactionMiddle) {
std::vector<ThreadStatus> thread_list; std::vector<ThreadStatus> thread_list;
// Delay both flush and compaction // Delay both flush and compaction
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBTest::PreShutdownCompactionMiddle:Preshutdown", {{"DBTest::PreShutdownCompactionMiddle:Preshutdown",
"CompactionJob::Run():Inprogress"}, "CompactionJob::Run():Inprogress"},
{"CompactionJob::Run():Start", {"CompactionJob::Run():Start",
@ -4471,7 +4468,7 @@ TEST_P(DBTestWithParam, PreShutdownCompactionMiddle) {
{"CompactionJob::Run():End", {"CompactionJob::Run():End",
"DBTest::PreShutdownCompactionMiddle:VerifyPreshutdown"}}); "DBTest::PreShutdownCompactionMiddle:VerifyPreshutdown"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Make rocksdb busy // Make rocksdb busy
int key = 0; int key = 0;
@ -4648,7 +4645,7 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
std::atomic<int> num_zlib(0); std::atomic<int> num_zlib(0);
std::atomic<int> num_lz4(0); std::atomic<int> num_lz4(0);
std::atomic<int> num_no(0); std::atomic<int> num_no(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
if (compaction->output_level() == 4) { if (compaction->output_level() == 4) {
@ -4656,13 +4653,13 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
num_lz4.fetch_add(1); num_lz4.fetch_add(1);
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"FlushJob::WriteLevel0Table:output_compression", [&](void* arg) { "FlushJob::WriteLevel0Table:output_compression", [&](void* arg) {
auto* compression = reinterpret_cast<CompressionType*>(arg); auto* compression = reinterpret_cast<CompressionType*>(arg);
ASSERT_TRUE(*compression == kNoCompression); ASSERT_TRUE(*compression == kNoCompression);
num_no.fetch_add(1); num_no.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
std::string value = RandomString(&rnd, 200); std::string value = RandomString(&rnd, 200);
@ -4676,8 +4673,8 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
Flush(); Flush();
dbfull()->TEST_WaitForFlushMemTable(); dbfull()->TEST_WaitForFlushMemTable();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
ASSERT_EQ(NumTableFilesAtLevel(1), 0); ASSERT_EQ(NumTableFilesAtLevel(1), 0);
ASSERT_EQ(NumTableFilesAtLevel(2), 0); ASSERT_EQ(NumTableFilesAtLevel(2), 0);
@ -4690,7 +4687,7 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
// After base level turn L4->L3, L3 becomes LZ4 and L4 becomes Zlib // After base level turn L4->L3, L3 becomes LZ4 and L4 becomes Zlib
num_lz4.store(0); num_lz4.store(0);
num_no.store(0); num_no.store(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) { "LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
if (compaction->output_level() == 4 && compaction->start_level() == 3) { if (compaction->output_level() == 4 && compaction->start_level() == 3) {
@ -4701,13 +4698,13 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
num_lz4.fetch_add(1); num_lz4.fetch_add(1);
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"FlushJob::WriteLevel0Table:output_compression", [&](void* arg) { "FlushJob::WriteLevel0Table:output_compression", [&](void* arg) {
auto* compression = reinterpret_cast<CompressionType*>(arg); auto* compression = reinterpret_cast<CompressionType*>(arg);
ASSERT_TRUE(*compression == kNoCompression); ASSERT_TRUE(*compression == kNoCompression);
num_no.fetch_add(1); num_no.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int i = 101; i < 500; i++) { for (int i = 101; i < 500; i++) {
std::string value = RandomString(&rnd, 200); std::string value = RandomString(&rnd, 200);
@ -4718,8 +4715,8 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
} }
} }
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(NumTableFilesAtLevel(1), 0); ASSERT_EQ(NumTableFilesAtLevel(1), 0);
ASSERT_EQ(NumTableFilesAtLevel(2), 0); ASSERT_EQ(NumTableFilesAtLevel(2), 0);
ASSERT_GT(NumTableFilesAtLevel(3), 0); ASSERT_GT(NumTableFilesAtLevel(3), 0);
@ -5135,7 +5132,7 @@ TEST_F(DBTest, DynamicMiscOptions) {
options.create_if_missing = true; options.create_if_missing = true;
options.max_sequential_skip_in_iterations = 16; options.max_sequential_skip_in_iterations = 16;
options.compression = kNoCompression; options.compression = kNoCompression;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
auto assert_reseek_count = [this, &options](int key_start, int num_reseek) { auto assert_reseek_count = [this, &options](int key_start, int num_reseek) {
@ -5227,7 +5224,7 @@ TEST_F(DBTest, L0L1L2AndUpHitCounter) {
options.max_write_buffer_number = 2; options.max_write_buffer_number = 2;
options.max_background_compactions = 8; options.max_background_compactions = 8;
options.max_background_flushes = 8; options.max_background_flushes = 8;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
CreateAndReopenWithCF({"mypikachu"}, options); CreateAndReopenWithCF({"mypikachu"}, options);
int numkeys = 20000; int numkeys = 20000;
@ -5330,7 +5327,7 @@ TEST_F(DBTest, CloseSpeedup) {
env_->DeleteDir(dbname_); env_->DeleteDir(dbname_);
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
env_->SetBackgroundThreads(1, Env::LOW); env_->SetBackgroundThreads(1, Env::LOW);
env_->SetBackgroundThreads(1, Env::HIGH); env_->SetBackgroundThreads(1, Env::HIGH);
Random rnd(301); Random rnd(301);
@ -5385,7 +5382,7 @@ TEST_F(DBTest, MergeTestTime) {
this->env_->time_elapse_only_sleep_ = true; this->env_->time_elapse_only_sleep_ = true;
this->env_->no_slowdown_ = true; this->env_->no_slowdown_ = true;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.merge_operator.reset(new DelayedMergeOperator(this)); options.merge_operator.reset(new DelayedMergeOperator(this));
DestroyAndReopen(options); DestroyAndReopen(options);
@ -5426,7 +5423,7 @@ TEST_P(DBTestWithParam, MergeCompactionTimeTest) {
SetPerfLevel(kEnableTime); SetPerfLevel(kEnableTime);
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_filter_factory = std::make_shared<KeepFilterFactory>(); options.compaction_filter_factory = std::make_shared<KeepFilterFactory>();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.merge_operator.reset(new DelayedMergeOperator(this)); options.merge_operator.reset(new DelayedMergeOperator(this));
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
options.max_subcompactions = max_subcompactions_; options.max_subcompactions = max_subcompactions_;
@ -5448,7 +5445,7 @@ TEST_P(DBTestWithParam, FilterCompactionTimeTest) {
std::make_shared<DelayFilterFactory>(this); std::make_shared<DelayFilterFactory>(this);
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.statistics->set_stats_level(kExceptTimeForMutex); options.statistics->set_stats_level(kExceptTimeForMutex);
options.max_subcompactions = max_subcompactions_; options.max_subcompactions = max_subcompactions_;
DestroyAndReopen(options); DestroyAndReopen(options);
@ -5712,16 +5709,16 @@ TEST_F(DBTest, AutomaticConflictsWithManualCompaction) {
// schedule automatic compactions after the manual one starts, but before it // schedule automatic compactions after the manual one starts, but before it
// finishes to ensure conflict. // finishes to ensure conflict.
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::BackgroundCompaction:Start", {{"DBImpl::BackgroundCompaction:Start",
"DBTest::AutomaticConflictsWithManualCompaction:PrePuts"}, "DBTest::AutomaticConflictsWithManualCompaction:PrePuts"},
{"DBTest::AutomaticConflictsWithManualCompaction:PostPuts", {"DBTest::AutomaticConflictsWithManualCompaction:PostPuts",
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun"}}); "DBImpl::BackgroundCompaction:NonTrivial:AfterRun"}});
std::atomic<int> callback_count(0); std::atomic<int> callback_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MaybeScheduleFlushOrCompaction:Conflict", "DBImpl::MaybeScheduleFlushOrCompaction:Conflict",
[&](void* /*arg*/) { callback_count.fetch_add(1); }); [&](void* /*arg*/) { callback_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
@ -5751,7 +5748,7 @@ TEST_F(DBTest, AutomaticConflictsWithManualCompaction) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
ASSERT_NE("NOT_FOUND", Get(Key(i))); ASSERT_NE("NOT_FOUND", Get(Key(i)));
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
manual_compaction_thread.join(); manual_compaction_thread.join();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
} }
@ -5775,7 +5772,7 @@ TEST_F(DBTest, CompactFilesShouldTriggerAutoCompaction) {
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
rocksdb::ColumnFamilyMetaData cf_meta_data; ROCKSDB_NAMESPACE::ColumnFamilyMetaData cf_meta_data;
db_->GetColumnFamilyMetaData(db_->DefaultColumnFamily(), &cf_meta_data); db_->GetColumnFamilyMetaData(db_->DefaultColumnFamily(), &cf_meta_data);
std::vector<std::string> input_files; std::vector<std::string> input_files;
@ -5879,19 +5876,19 @@ TEST_F(DBTest, FlushesInParallelWithCompactRange) {
} }
if (iter == 1) { if (iter == 1) {
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::RunManualCompaction()::1", {{"DBImpl::RunManualCompaction()::1",
"DBTest::FlushesInParallelWithCompactRange:1"}, "DBTest::FlushesInParallelWithCompactRange:1"},
{"DBTest::FlushesInParallelWithCompactRange:2", {"DBTest::FlushesInParallelWithCompactRange:2",
"DBImpl::RunManualCompaction()::2"}}); "DBImpl::RunManualCompaction()::2"}});
} else { } else {
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"CompactionJob::Run():Start", {{"CompactionJob::Run():Start",
"DBTest::FlushesInParallelWithCompactRange:1"}, "DBTest::FlushesInParallelWithCompactRange:1"},
{"DBTest::FlushesInParallelWithCompactRange:2", {"DBTest::FlushesInParallelWithCompactRange:2",
"CompactionJob::Run():End"}}); "CompactionJob::Run():End"}});
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<port::Thread> threads; std::vector<port::Thread> threads;
threads.emplace_back([&]() { Compact("a", "z"); }); threads.emplace_back([&]() { Compact("a", "z"); });
@ -5910,7 +5907,7 @@ TEST_F(DBTest, FlushesInParallelWithCompactRange) {
for (auto& t : threads) { for (auto& t : threads) {
t.join(); t.join();
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
} }
@ -5976,7 +5973,7 @@ TEST_F(DBTest, DelayedWriteRate) {
static_cast<int64_t>(estimated_sleep_time * 2)); static_cast<int64_t>(estimated_sleep_time * 2));
env_->no_slowdown_ = false; env_->no_slowdown_ = false;
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
sleeping_task_low.WakeUp(); sleeping_task_low.WakeUp();
sleeping_task_low.WaitUntilDone(); sleeping_task_low.WaitUntilDone();
} }
@ -6005,12 +6002,12 @@ TEST_F(DBTest, HardLimit) {
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
std::atomic<int> callback_count(0); std::atomic<int> callback_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack("DBImpl::DelayWrite:Wait", ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
[&](void* /*arg*/) { "DBImpl::DelayWrite:Wait", [&](void* /*arg*/) {
callback_count.fetch_add(1); callback_count.fetch_add(1);
sleeping_task_low.WakeUp(); sleeping_task_low.WakeUp();
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
int key_idx = 0; int key_idx = 0;
@ -6027,7 +6024,7 @@ TEST_F(DBTest, HardLimit) {
} }
ASSERT_GE(callback_count.load(), 1); ASSERT_GE(callback_count.load(), 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
sleeping_task_low.WaitUntilDone(); sleeping_task_low.WaitUntilDone();
} }
@ -6099,7 +6096,7 @@ TEST_F(DBTest, SoftLimit) {
"DBImpl::BackgroundCallFlush:ContextCleanedUp"); "DBImpl::BackgroundCallFlush:ContextCleanedUp");
}; };
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Reopen(options); Reopen(options);
@ -6155,7 +6152,7 @@ TEST_F(DBTest, SoftLimit) {
ASSERT_TRUE(listener->CheckCondition(WriteStallCondition::kNormal)); ASSERT_TRUE(listener->CheckCondition(WriteStallCondition::kNormal));
// Only allow one compactin going through. // Only allow one compactin going through.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BackgroundCallCompaction:0", [&](void* /*arg*/) { "BackgroundCallCompaction:0", [&](void* /*arg*/) {
// Schedule a sleeping task. // Schedule a sleeping task.
sleeping_task_low.Reset(); sleeping_task_low.Reset();
@ -6229,7 +6226,7 @@ TEST_F(DBTest, SoftLimit) {
ASSERT_TRUE(listener->CheckCondition(WriteStallCondition::kDelayed)); ASSERT_TRUE(listener->CheckCondition(WriteStallCondition::kDelayed));
sleeping_task_low.WaitUntilSleeping(); sleeping_task_low.WaitUntilSleeping();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
sleeping_task_low.WakeUp(); sleeping_task_low.WakeUp();
sleeping_task_low.WaitUntilDone(); sleeping_task_low.WaitUntilDone();
} }
@ -6307,7 +6304,7 @@ TEST_F(DBTest, CreateColumnFamilyShouldFailOnIncompatibleOptions) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
TEST_F(DBTest, RowCache) { TEST_F(DBTest, RowCache) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.row_cache = NewLRUCache(8192); options.row_cache = NewLRUCache(8192);
DestroyAndReopen(options); DestroyAndReopen(options);
@ -6326,7 +6323,7 @@ TEST_F(DBTest, RowCache) {
TEST_F(DBTest, PinnableSliceAndRowCache) { TEST_F(DBTest, PinnableSliceAndRowCache) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.row_cache = NewLRUCache(8192); options.row_cache = NewLRUCache(8192);
DestroyAndReopen(options); DestroyAndReopen(options);
@ -6356,12 +6353,12 @@ TEST_F(DBTest, PinnableSliceAndRowCache) {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
TEST_F(DBTest, DeletingOldWalAfterDrop) { TEST_F(DBTest, DeletingOldWalAfterDrop) {
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"Test:AllowFlushes", "DBImpl::BGWorkFlush"}, {{"Test:AllowFlushes", "DBImpl::BGWorkFlush"},
{"DBImpl::BGWorkFlush:done", "Test:WaitForFlush"}}); {"DBImpl::BGWorkFlush:done", "Test:WaitForFlush"}});
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_total_wal_size = 8192; options.max_total_wal_size = 8192;
options.compression = kNoCompression; options.compression = kNoCompression;
@ -6371,7 +6368,7 @@ TEST_F(DBTest, DeletingOldWalAfterDrop) {
options.level0_stop_writes_trigger = (1 << 30); options.level0_stop_writes_trigger = (1 << 30);
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
CreateColumnFamilies({"cf1", "cf2"}, options); CreateColumnFamilies({"cf1", "cf2"}, options);
ASSERT_OK(Put(0, "key1", DummyString(8192))); ASSERT_OK(Put(0, "key1", DummyString(8192)));
@ -6509,7 +6506,7 @@ TEST_F(DBTest, CreationTimeOfOldestFile) {
env_->GetCurrentTime(&time_2); env_->GetCurrentTime(&time_2);
const uint64_t uint_time_2 = static_cast<uint64_t>(time_2); const uint64_t uint_time_2 = static_cast<uint64_t>(time_2);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"PropertyBlockBuilder::AddTableProperty:Start", [&](void* arg) { "PropertyBlockBuilder::AddTableProperty:Start", [&](void* arg) {
TableProperties* props = reinterpret_cast<TableProperties*>(arg); TableProperties* props = reinterpret_cast<TableProperties*>(arg);
if (set_file_creation_time_to_zero) { if (set_file_creation_time_to_zero) {
@ -6530,12 +6527,12 @@ TEST_F(DBTest, CreationTimeOfOldestFile) {
} }
}); });
// Set file creation time in manifest all to 0. // Set file creation time in manifest all to 0.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"FileMetaData::FileMetaData", [&](void* arg) { "FileMetaData::FileMetaData", [&](void* arg) {
FileMetaData* meta = static_cast<FileMetaData*>(arg); FileMetaData* meta = static_cast<FileMetaData*>(arg);
meta->file_creation_time = 0; meta->file_creation_time = 0;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int i = 0; i < kNumLevelFiles; ++i) { for (int i = 0; i < kNumLevelFiles; ++i) {
@ -6585,12 +6582,12 @@ TEST_F(DBTest, CreationTimeOfOldestFile) {
Status s3 = dbfull()->GetCreationTimeOfOldestFile(&ctime); Status s3 = dbfull()->GetCreationTimeOfOldestFile(&ctime);
ASSERT_EQ(s3, Status::NotSupported()); ASSERT_EQ(s3, Status::NotSupported());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif #endif
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
extern "C" { extern "C" {
@ -6601,7 +6598,7 @@ void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
#endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
RegisterCustomObjects(argc, argv); RegisterCustomObjects(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -18,7 +18,7 @@
#include "rocksdb/wal_filter.h" #include "rocksdb/wal_filter.h"
#include "test_util/fault_injection_test_env.h" #include "test_util/fault_injection_test_env.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBTest2 : public DBTestBase { class DBTest2 : public DBTestBase {
public: public:
@ -40,7 +40,7 @@ TEST_P(PrefixFullBloomWithReverseComparator,
Options options = last_options_; Options options = last_options_;
options.comparator = ReverseBytewiseComparator(); options.comparator = ReverseBytewiseComparator();
options.prefix_extractor.reset(NewCappedPrefixTransform(3)); options.prefix_extractor.reset(NewCappedPrefixTransform(3));
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
if (if_cache_filter_) { if (if_cache_filter_) {
bbto.no_block_cache = false; bbto.no_block_cache = false;
@ -132,7 +132,7 @@ TEST_F(DBTest2, IteratorPropertyVersionNumber) {
TEST_F(DBTest2, CacheIndexAndFilterWithDBRestart) { TEST_F(DBTest2, CacheIndexAndFilterWithDBRestart) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
table_options.filter_policy.reset(NewBloomFilterPolicy(20)); table_options.filter_policy.reset(NewBloomFilterPolicy(20));
@ -151,7 +151,7 @@ TEST_F(DBTest2, CacheIndexAndFilterWithDBRestart) {
TEST_F(DBTest2, MaxSuccessiveMergesChangeWithDBRecovery) { TEST_F(DBTest2, MaxSuccessiveMergesChangeWithDBRecovery) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.max_successive_merges = 3; options.max_successive_merges = 3;
options.merge_operator = MergeOperators::CreatePutOperator(); options.merge_operator = MergeOperators::CreatePutOperator();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
@ -185,19 +185,19 @@ TEST_P(DBTestSharedWriteBufferAcrossCFs, SharedWriteBufferAcrossCFs) {
// Avoid undeterministic value by malloc_usable_size(); // Avoid undeterministic value by malloc_usable_size();
// Force arena block size to 1 // Force arena block size to 1
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Arena::Arena:0", [&](void* arg) { "Arena::Arena:0", [&](void* arg) {
size_t* block_size = static_cast<size_t*>(arg); size_t* block_size = static_cast<size_t*>(arg);
*block_size = 1; *block_size = 1;
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Arena::AllocateNewBlock:0", [&](void* arg) { "Arena::AllocateNewBlock:0", [&](void* arg) {
std::pair<size_t*, size_t*>* pair = std::pair<size_t*, size_t*>* pair =
static_cast<std::pair<size_t*, size_t*>*>(arg); static_cast<std::pair<size_t*, size_t*>*>(arg);
*std::get<0>(*pair) = *std::get<1>(*pair); *std::get<0>(*pair) = *std::get<1>(*pair);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// The total soft write buffer size is about 105000 // The total soft write buffer size is about 105000
std::shared_ptr<Cache> cache = NewLRUCache(4 * 1024 * 1024, 2); std::shared_ptr<Cache> cache = NewLRUCache(4 * 1024 * 1024, 2);
@ -346,7 +346,7 @@ TEST_P(DBTestSharedWriteBufferAcrossCFs, SharedWriteBufferAcrossCFs) {
last_options_.write_buffer_manager.reset(); last_options_.write_buffer_manager.reset();
ASSERT_LT(cache->GetUsage(), 256 * 1024); ASSERT_LT(cache->GetUsage(), 256 * 1024);
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
INSTANTIATE_TEST_CASE_P(DBTestSharedWriteBufferAcrossCFs, INSTANTIATE_TEST_CASE_P(DBTestSharedWriteBufferAcrossCFs,
@ -361,19 +361,19 @@ TEST_F(DBTest2, SharedWriteBufferLimitAcrossDB) {
options.arena_block_size = 4096; options.arena_block_size = 4096;
// Avoid undeterministic value by malloc_usable_size(); // Avoid undeterministic value by malloc_usable_size();
// Force arena block size to 1 // Force arena block size to 1
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Arena::Arena:0", [&](void* arg) { "Arena::Arena:0", [&](void* arg) {
size_t* block_size = static_cast<size_t*>(arg); size_t* block_size = static_cast<size_t*>(arg);
*block_size = 1; *block_size = 1;
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Arena::AllocateNewBlock:0", [&](void* arg) { "Arena::AllocateNewBlock:0", [&](void* arg) {
std::pair<size_t*, size_t*>* pair = std::pair<size_t*, size_t*>* pair =
static_cast<std::pair<size_t*, size_t*>*>(arg); static_cast<std::pair<size_t*, size_t*>*>(arg);
*std::get<0>(*pair) = *std::get<1>(*pair); *std::get<0>(*pair) = *std::get<1>(*pair);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
options.write_buffer_size = 500000; // this is never hit options.write_buffer_size = 500000; // this is never hit
// Use a write buffer total size so that the soft limit is about // Use a write buffer total size so that the soft limit is about
@ -453,7 +453,7 @@ TEST_F(DBTest2, SharedWriteBufferLimitAcrossDB) {
delete db2; delete db2;
ASSERT_OK(DestroyDB(dbname2, options)); ASSERT_OK(DestroyDB(dbname2, options));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, TestWriteBufferNoLimitWithCache) { TEST_F(DBTest2, TestWriteBufferNoLimitWithCache) {
@ -1114,7 +1114,7 @@ TEST_F(DBTest2, PresetCompressionDict) {
assert(false); assert(false);
} }
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.table_factory.reset(NewBlockBasedTableFactory(table_options)); options.table_factory.reset(NewBlockBasedTableFactory(table_options));
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
Random rnd(301); Random rnd(301);
@ -1185,7 +1185,7 @@ TEST_F(DBTest2, PresetCompressionDictLocality) {
options.compression = kZSTD; options.compression = kZSTD;
options.compression_opts.max_dict_bytes = 1 << 14; // 16KB options.compression_opts.max_dict_bytes = 1 << 14; // 16KB
options.compression_opts.zstd_max_train_bytes = 1 << 18; // 256KB options.compression_opts.zstd_max_train_bytes = 1 << 18; // 256KB
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.target_file_size_base = kNumEntriesPerFile * kNumBytesPerEntry; options.target_file_size_base = kNumEntriesPerFile * kNumBytesPerEntry;
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
@ -1205,12 +1205,12 @@ TEST_F(DBTest2, PresetCompressionDictLocality) {
// Store all the dictionaries generated during a full compaction. // Store all the dictionaries generated during a full compaction.
std::vector<std::string> compression_dicts; std::vector<std::string> compression_dicts;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BlockBasedTableBuilder::WriteCompressionDictBlock:RawDict", "BlockBasedTableBuilder::WriteCompressionDictBlock:RawDict",
[&](void* arg) { [&](void* arg) {
compression_dicts.emplace_back(static_cast<Slice*>(arg)->ToString()); compression_dicts.emplace_back(static_cast<Slice*>(arg)->ToString());
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
CompactRangeOptions compact_range_opts; CompactRangeOptions compact_range_opts;
compact_range_opts.bottommost_level_compaction = compact_range_opts.bottommost_level_compaction =
BottommostLevelCompaction::kForceOptimized; BottommostLevelCompaction::kForceOptimized;
@ -1351,14 +1351,14 @@ class CompactionStallTestListener : public EventListener {
}; };
TEST_F(DBTest2, CompactionStall) { TEST_F(DBTest2, CompactionStall) {
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::BGWorkCompaction", "DBTest2::CompactionStall:0"}, {{"DBImpl::BGWorkCompaction", "DBTest2::CompactionStall:0"},
{"DBImpl::BGWorkCompaction", "DBTest2::CompactionStall:1"}, {"DBImpl::BGWorkCompaction", "DBTest2::CompactionStall:1"},
{"DBTest2::CompactionStall:2", {"DBTest2::CompactionStall:2",
"DBImpl::NotifyOnCompactionBegin::UnlockMutex"}, "DBImpl::NotifyOnCompactionBegin::UnlockMutex"},
{"DBTest2::CompactionStall:3", {"DBTest2::CompactionStall:3",
"DBImpl::NotifyOnCompactionCompleted::UnlockMutex"}}); "DBImpl::NotifyOnCompactionCompleted::UnlockMutex"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.level0_file_num_compaction_trigger = 4; options.level0_file_num_compaction_trigger = 4;
@ -1385,7 +1385,7 @@ TEST_F(DBTest2, CompactionStall) {
// Clear "DBImpl::BGWorkCompaction" SYNC_POINT since we want to hold it again // Clear "DBImpl::BGWorkCompaction" SYNC_POINT since we want to hold it again
// at DBTest2::CompactionStall::1 // at DBTest2::CompactionStall::1
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
// Another 6 L0 files to trigger compaction again // Another 6 L0 files to trigger compaction again
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -1411,7 +1411,7 @@ TEST_F(DBTest2, CompactionStall) {
10 - options.level0_file_num_compaction_trigger); 10 - options.level0_file_num_compaction_trigger);
ASSERT_EQ(listener->compacting_files_cnt_.load(), listener->compacted_files_cnt_.load()); ASSERT_EQ(listener->compacting_files_cnt_.load(), listener->compacted_files_cnt_.load());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -1480,7 +1480,7 @@ class PinL0IndexAndFilterBlocksTest
options->max_open_files = -1; options->max_open_files = -1;
} }
options->create_if_missing = true; options->create_if_missing = true;
options->statistics = rocksdb::CreateDBStatistics(); options->statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
table_options.pin_l0_filter_and_index_blocks_in_cache = true; table_options.pin_l0_filter_and_index_blocks_in_cache = true;
@ -1520,7 +1520,7 @@ TEST_P(PinL0IndexAndFilterBlocksTest,
options.max_open_files = -1; options.max_open_files = -1;
} }
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions table_options; BlockBasedTableOptions table_options;
table_options.cache_index_and_filter_blocks = true; table_options.cache_index_and_filter_blocks = true;
table_options.pin_l0_filter_and_index_blocks_in_cache = true; table_options.pin_l0_filter_and_index_blocks_in_cache = true;
@ -1606,20 +1606,20 @@ TEST_P(PinL0IndexAndFilterBlocksTest, DisablePrefetchingNonL0IndexAndFilter) {
// so that preloading SST files won't happen. // so that preloading SST files won't happen.
options.max_open_files = 13; options.max_open_files = 13;
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = 13; *max_open_files = 13;
}); });
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Reopen database. If max_open_files is set as -1, table readers will be // Reopen database. If max_open_files is set as -1, table readers will be
// preloaded. This will trigger a BlockBasedTable::Open() and prefetch // preloaded. This will trigger a BlockBasedTable::Open() and prefetch
// L0 index and filter. Level 1's prefetching is disabled in DB::Open() // L0 index and filter. Level 1's prefetching is disabled in DB::Open()
TryReopenWithColumnFamilies({"default", "pikachu"}, options); TryReopenWithColumnFamilies({"default", "pikachu"}, options);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
if (!disallow_preload_) { if (!disallow_preload_) {
// After reopen, cache miss are increased by one because we read (and only // After reopen, cache miss are increased by one because we read (and only
@ -1759,8 +1759,8 @@ static void UniqueIdCallback(void* arg) {
*result = 0; *result = 0;
} }
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback); "GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback);
} }
@ -1768,8 +1768,8 @@ class MockPersistentCache : public PersistentCache {
public: public:
explicit MockPersistentCache(const bool is_compressed, const size_t max_size) explicit MockPersistentCache(const bool is_compressed, const size_t max_size)
: is_compressed_(is_compressed), max_size_(max_size) { : is_compressed_(is_compressed), max_size_(max_size) {
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback); "GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback);
} }
@ -1841,10 +1841,10 @@ TEST_F(DBTest2, TestPerfContextGetCpuTime) {
uint64_t kDummyAddonTime = uint64_t{1000000000000}; uint64_t kDummyAddonTime = uint64_t{1000000000000};
// Add time to NowNanos() reading. // Add time to NowNanos() reading.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"TableCache::FindTable:0", "TableCache::FindTable:0",
[&](void* /*arg*/) { env_->addon_time_.fetch_add(kDummyAddonTime); }); [&](void* /*arg*/) { env_->addon_time_.fetch_add(kDummyAddonTime); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
SetPerfLevel(PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); SetPerfLevel(PerfLevel::kEnableTimeAndCPUTimeExceptForMutex);
ASSERT_EQ("bar", Get("foo")); ASSERT_EQ("bar", Get("foo"));
@ -1853,7 +1853,7 @@ TEST_F(DBTest2, TestPerfContextGetCpuTime) {
ASSERT_GT(get_perf_context()->find_table_nanos, kDummyAddonTime); ASSERT_GT(get_perf_context()->find_table_nanos, kDummyAddonTime);
SetPerfLevel(PerfLevel::kDisable); SetPerfLevel(PerfLevel::kDisable);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, TestPerfContextIterCpuTime) { TEST_F(DBTest2, TestPerfContextIterCpuTime) {
@ -1903,10 +1903,10 @@ TEST_F(DBTest2, TestPerfContextIterCpuTime) {
uint64_t kDummyAddonTime = uint64_t{1000000000000}; uint64_t kDummyAddonTime = uint64_t{1000000000000};
// Add time to NowNanos() reading. // Add time to NowNanos() reading.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"TableCache::FindTable:0", "TableCache::FindTable:0",
[&](void* /*arg*/) { env_->addon_time_.fetch_add(kDummyAddonTime); }); [&](void* /*arg*/) { env_->addon_time_.fetch_add(kDummyAddonTime); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
SetPerfLevel(PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); SetPerfLevel(PerfLevel::kEnableTimeAndCPUTimeExceptForMutex);
iter = db_->NewIterator(ReadOptions()); iter = db_->NewIterator(ReadOptions());
@ -1937,7 +1937,7 @@ TEST_F(DBTest2, TestPerfContextIterCpuTime) {
ASSERT_GT(get_perf_context()->find_table_nanos, kDummyAddonTime); ASSERT_GT(get_perf_context()->find_table_nanos, kDummyAddonTime);
SetPerfLevel(PerfLevel::kDisable); SetPerfLevel(PerfLevel::kDisable);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
delete iter; delete iter;
} }
#endif // OS_LINUX #endif // OS_LINUX
@ -1951,7 +1951,7 @@ TEST_F(DBTest2, PersistentCache) {
Options options; Options options;
options.write_buffer_size = 64 * 1024; // small write buffer options.write_buffer_size = 64 * 1024; // small write buffer
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options = CurrentOptions(options); options = CurrentOptions(options);
auto bsizes = {/*no block cache*/ 0, /*1M*/ 1 * 1024 * 1024}; auto bsizes = {/*no block cache*/ 0, /*1M*/ 1 * 1024 * 1024};
@ -2019,7 +2019,7 @@ void CountSyncPoint() {
TEST_F(DBTest2, SyncPointMarker) { TEST_F(DBTest2, SyncPointMarker) {
std::atomic<int> sync_point_called(0); std::atomic<int> sync_point_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTest2::MarkedPoint", "DBTest2::MarkedPoint",
[&](void* /*arg*/) { sync_point_called.fetch_add(1); }); [&](void* /*arg*/) { sync_point_called.fetch_add(1); });
@ -2031,11 +2031,11 @@ TEST_F(DBTest2, SyncPointMarker) {
// | MarkedPoint | | // | MarkedPoint | |
// | Thread1First | | // | Thread1First | |
// | | MarkedPoint | // | | MarkedPoint |
rocksdb::SyncPoint::GetInstance()->LoadDependencyAndMarkers( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependencyAndMarkers(
{{"DBTest2::SyncPointMarker:Thread1First", "DBTest2::MarkedPoint"}}, {{"DBTest2::SyncPointMarker:Thread1First", "DBTest2::MarkedPoint"}},
{{"DBTest2::SyncPointMarker:Marker", "DBTest2::MarkedPoint"}}); {{"DBTest2::SyncPointMarker:Marker", "DBTest2::MarkedPoint"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::function<void()> func1 = [&]() { std::function<void()> func1 = [&]() {
CountSyncPoint(); CountSyncPoint();
@ -2054,7 +2054,7 @@ TEST_F(DBTest2, SyncPointMarker) {
// Callback is only executed once // Callback is only executed once
ASSERT_EQ(sync_point_called.load(), 1); ASSERT_EQ(sync_point_called.load(), 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif #endif
@ -2079,7 +2079,7 @@ TEST_F(DBTest2, ReadAmpBitmap) {
bbto.block_cache = NewLRUCache(1024 * 1024 * 1024); bbto.block_cache = NewLRUCache(1024 * 1024 * 1024);
bbto.read_amp_bytes_per_bit = bytes_per_bit[k]; bbto.read_amp_bytes_per_bit = bytes_per_bit[k];
options.table_factory.reset(NewBlockBasedTableFactory(bbto)); options.table_factory.reset(NewBlockBasedTableFactory(bbto));
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
DestroyAndReopen(options); DestroyAndReopen(options);
const size_t kNumEntries = 10000; const size_t kNumEntries = 10000;
@ -2176,7 +2176,7 @@ TEST_F(DBTest2, ReadAmpBitmapLiveInCacheAfterDBClose) {
uint32_t bytes_per_bit[2] = {1, 16}; uint32_t bytes_per_bit[2] = {1, 16};
for (size_t k = 0; k < 2; k++) { for (size_t k = 0; k < 2; k++) {
std::shared_ptr<Cache> lru_cache = NewLRUCache(1024 * 1024 * 1024); std::shared_ptr<Cache> lru_cache = NewLRUCache(1024 * 1024 * 1024);
std::shared_ptr<Statistics> stats = rocksdb::CreateDBStatistics(); std::shared_ptr<Statistics> stats = ROCKSDB_NAMESPACE::CreateDBStatistics();
Options options = CurrentOptions(); Options options = CurrentOptions();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
@ -2223,7 +2223,8 @@ TEST_F(DBTest2, ReadAmpBitmapLiveInCacheAfterDBClose) {
options.statistics->getTickerCount(READ_AMP_TOTAL_READ_BYTES); options.statistics->getTickerCount(READ_AMP_TOTAL_READ_BYTES);
Close(); Close();
std::shared_ptr<Statistics> new_statistics = rocksdb::CreateDBStatistics(); std::shared_ptr<Statistics> new_statistics =
ROCKSDB_NAMESPACE::CreateDBStatistics();
// Destroy old statistics obj that the blocks in lru_cache are pointing to // Destroy old statistics obj that the blocks in lru_cache are pointing to
options.statistics.reset(); options.statistics.reset();
// Use the statistics object that we just created // Use the statistics object that we just created
@ -2307,7 +2308,7 @@ TEST_F(DBTest2, AutomaticCompactionOverlapManualCompaction) {
// While the compaction is running, we will create 2 new files that // While the compaction is running, we will create 2 new files that
// can fit in L2, these 2 files will be moved to L2 and overlap with // can fit in L2, these 2 files will be moved to L2 and overlap with
// the running compaction and break the LSM consistency. // the running compaction and break the LSM consistency.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start", [&](void* /*arg*/) { "CompactionJob::Run():Start", [&](void* /*arg*/) {
ASSERT_OK( ASSERT_OK(
dbfull()->SetOptions({{"level0_file_num_compaction_trigger", "2"}, dbfull()->SetOptions({{"level0_file_num_compaction_trigger", "2"},
@ -2320,7 +2321,7 @@ TEST_F(DBTest2, AutomaticCompactionOverlapManualCompaction) {
ASSERT_OK(Put(Key(9), "a")); ASSERT_OK(Put(Key(9), "a"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Run a manual compaction that will compact the 2 files in L2 // Run a manual compaction that will compact the 2 files in L2
// into 1 file in L2 // into 1 file in L2
@ -2328,7 +2329,7 @@ TEST_F(DBTest2, AutomaticCompactionOverlapManualCompaction) {
cro.bottommost_level_compaction = BottommostLevelCompaction::kForceOptimized; cro.bottommost_level_compaction = BottommostLevelCompaction::kForceOptimized;
ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr)); ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
// Test that the stats GetMapProperty API reporting 1 file in L2 // Test that the stats GetMapProperty API reporting 1 file in L2
{ {
@ -2367,13 +2368,13 @@ TEST_F(DBTest2, ManualCompactionOverlapManualCompaction) {
cro.exclusive_manual_compaction = false; cro.exclusive_manual_compaction = false;
ASSERT_OK(db_->CompactRange(cro, &k1s, &k2s)); ASSERT_OK(db_->CompactRange(cro, &k1s, &k2s));
}; };
rocksdb::port::Thread bg_thread; ROCKSDB_NAMESPACE::port::Thread bg_thread;
// While the compaction is running, we will create 2 new files that // While the compaction is running, we will create 2 new files that
// can fit in L1, these 2 files will be moved to L1 and overlap with // can fit in L1, these 2 files will be moved to L1 and overlap with
// the running compaction and break the LSM consistency. // the running compaction and break the LSM consistency.
std::atomic<bool> flag(false); std::atomic<bool> flag(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start", [&](void* /*arg*/) { "CompactionJob::Run():Start", [&](void* /*arg*/) {
if (flag.exchange(true)) { if (flag.exchange(true)) {
// We want to make sure to call this callback only once // We want to make sure to call this callback only once
@ -2393,7 +2394,7 @@ TEST_F(DBTest2, ManualCompactionOverlapManualCompaction) {
// so it should wait until the first compaction finish // so it should wait until the first compaction finish
env_->SleepForMicroseconds(1000000); env_->SleepForMicroseconds(1000000);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Run a manual compaction that will compact the 2 files in L1 // Run a manual compaction that will compact the 2 files in L1
// into 1 file in L1 // into 1 file in L1
@ -2403,7 +2404,7 @@ TEST_F(DBTest2, ManualCompactionOverlapManualCompaction) {
ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr)); ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr));
bg_thread.join(); bg_thread.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, PausingManualCompaction1) { TEST_F(DBTest2, PausingManualCompaction1) {
@ -2426,14 +2427,14 @@ TEST_F(DBTest2, PausingManualCompaction1) {
ASSERT_OK(Flush()); ASSERT_OK(Flush());
int manual_compactions_paused = 0; int manual_compactions_paused = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():PausingManualCompaction:1", [&](void* arg) { "CompactionJob::Run():PausingManualCompaction:1", [&](void* arg) {
auto paused = reinterpret_cast<std::atomic<bool>*>(arg); auto paused = reinterpret_cast<std::atomic<bool>*>(arg);
ASSERT_FALSE(paused->load(std::memory_order_acquire)); ASSERT_FALSE(paused->load(std::memory_order_acquire));
paused->store(true, std::memory_order_release); paused->store(true, std::memory_order_release);
manual_compactions_paused += 1; manual_compactions_paused += 1;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
std::vector<std::string> files_before_compact, files_after_compact; std::vector<std::string> files_before_compact, files_after_compact;
// Remember file name before compaction is triggered // Remember file name before compaction is triggered
@ -2462,7 +2463,8 @@ TEST_F(DBTest2, PausingManualCompaction1) {
manual_compactions_paused = 0; manual_compactions_paused = 0;
// Now make sure CompactFiles also not run // Now make sure CompactFiles also not run
dbfull()->CompactFiles(rocksdb::CompactionOptions(), files_before_compact, 0); dbfull()->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(),
files_before_compact, 0);
// Wait for manual compaction to get scheduled and finish // Wait for manual compaction to get scheduled and finish
dbfull()->TEST_WaitForCompact(true); dbfull()->TEST_WaitForCompact(true);
@ -2477,7 +2479,7 @@ TEST_F(DBTest2, PausingManualCompaction1) {
// CompactFiles returns at entry point // CompactFiles returns at entry point
ASSERT_EQ(manual_compactions_paused, 0); ASSERT_EQ(manual_compactions_paused, 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
// PausingManualCompaction does not affect auto compaction // PausingManualCompaction does not affect auto compaction
@ -2532,10 +2534,10 @@ TEST_F(DBTest2, PausingManualCompaction3) {
ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel()); ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
int run_manual_compactions = 0; int run_manual_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():PausingManualCompaction:1", "CompactionJob::Run():PausingManualCompaction:1",
[&](void* /*arg*/) { run_manual_compactions++; }); [&](void* /*arg*/) { run_manual_compactions++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->DisableManualCompaction(); dbfull()->DisableManualCompaction();
dbfull()->CompactRange(compact_options, nullptr, nullptr); dbfull()->CompactRange(compact_options, nullptr, nullptr);
@ -2546,7 +2548,7 @@ TEST_F(DBTest2, PausingManualCompaction3) {
ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel()); ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
rocksdb::SyncPoint::GetInstance()->ClearCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
"CompactionJob::Run():PausingManualCompaction:1"); "CompactionJob::Run():PausingManualCompaction:1");
dbfull()->EnableManualCompaction(); dbfull()->EnableManualCompaction();
dbfull()->CompactRange(compact_options, nullptr, nullptr); dbfull()->CompactRange(compact_options, nullptr, nullptr);
@ -2555,7 +2557,7 @@ TEST_F(DBTest2, PausingManualCompaction3) {
ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel()); ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, PausingManualCompaction4) { TEST_F(DBTest2, PausingManualCompaction4) {
@ -2586,14 +2588,14 @@ TEST_F(DBTest2, PausingManualCompaction4) {
ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel()); ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
int run_manual_compactions = 0; int run_manual_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():PausingManualCompaction:2", [&](void* arg) { "CompactionJob::Run():PausingManualCompaction:2", [&](void* arg) {
auto paused = reinterpret_cast<std::atomic<bool>*>(arg); auto paused = reinterpret_cast<std::atomic<bool>*>(arg);
ASSERT_FALSE(paused->load(std::memory_order_acquire)); ASSERT_FALSE(paused->load(std::memory_order_acquire));
paused->store(true, std::memory_order_release); paused->store(true, std::memory_order_release);
run_manual_compactions++; run_manual_compactions++;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->EnableManualCompaction(); dbfull()->EnableManualCompaction();
dbfull()->CompactRange(compact_options, nullptr, nullptr); dbfull()->CompactRange(compact_options, nullptr, nullptr);
@ -2603,7 +2605,7 @@ TEST_F(DBTest2, PausingManualCompaction4) {
ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel()); ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
rocksdb::SyncPoint::GetInstance()->ClearCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
"CompactionJob::Run():PausingManualCompaction:2"); "CompactionJob::Run():PausingManualCompaction:2");
dbfull()->EnableManualCompaction(); dbfull()->EnableManualCompaction();
dbfull()->CompactRange(compact_options, nullptr, nullptr); dbfull()->CompactRange(compact_options, nullptr, nullptr);
@ -2612,7 +2614,7 @@ TEST_F(DBTest2, PausingManualCompaction4) {
ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel()); ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, OptimizeForPointLookup) { TEST_F(DBTest2, OptimizeForPointLookup) {
@ -2667,13 +2669,13 @@ TEST_F(DBTest2, OptimizeForSmallDB) {
TEST_F(DBTest2, GetRaceFlush1) { TEST_F(DBTest2, GetRaceFlush1) {
ASSERT_OK(Put("foo", "v1")); ASSERT_OK(Put("foo", "v1"));
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::GetImpl:1", "DBTest2::GetRaceFlush:1"}, {{"DBImpl::GetImpl:1", "DBTest2::GetRaceFlush:1"},
{"DBTest2::GetRaceFlush:2", "DBImpl::GetImpl:2"}}); {"DBTest2::GetRaceFlush:2", "DBImpl::GetImpl:2"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread t1([&] { ROCKSDB_NAMESPACE::port::Thread t1([&] {
TEST_SYNC_POINT("DBTest2::GetRaceFlush:1"); TEST_SYNC_POINT("DBTest2::GetRaceFlush:1");
ASSERT_OK(Put("foo", "v2")); ASSERT_OK(Put("foo", "v2"));
Flush(); Flush();
@ -2684,17 +2686,17 @@ TEST_F(DBTest2, GetRaceFlush1) {
// "v1" or "v2". // "v1" or "v2".
ASSERT_NE("NOT_FOUND", Get("foo")); ASSERT_NE("NOT_FOUND", Get("foo"));
t1.join(); t1.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, GetRaceFlush2) { TEST_F(DBTest2, GetRaceFlush2) {
ASSERT_OK(Put("foo", "v1")); ASSERT_OK(Put("foo", "v1"));
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::GetImpl:3", "DBTest2::GetRaceFlush:1"}, {{"DBImpl::GetImpl:3", "DBTest2::GetRaceFlush:1"},
{"DBTest2::GetRaceFlush:2", "DBImpl::GetImpl:4"}}); {"DBTest2::GetRaceFlush:2", "DBImpl::GetImpl:4"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
port::Thread t1([&] { port::Thread t1([&] {
TEST_SYNC_POINT("DBTest2::GetRaceFlush:1"); TEST_SYNC_POINT("DBTest2::GetRaceFlush:1");
@ -2707,7 +2709,7 @@ TEST_F(DBTest2, GetRaceFlush2) {
// "v1" or "v2". // "v1" or "v2".
ASSERT_NE("NOT_FOUND", Get("foo")); ASSERT_NE("NOT_FOUND", Get("foo"));
t1.join(); t1.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, DirectIO) { TEST_F(DBTest2, DirectIO) {
@ -2807,17 +2809,17 @@ TEST_F(DBTest2, LowPriWrite) {
std::atomic<int> rate_limit_count(0); std::atomic<int> rate_limit_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"GenericRateLimiter::Request:1", [&](void* arg) { "GenericRateLimiter::Request:1", [&](void* arg) {
rate_limit_count.fetch_add(1); rate_limit_count.fetch_add(1);
int64_t* rate_bytes_per_sec = static_cast<int64_t*>(arg); int64_t* rate_bytes_per_sec = static_cast<int64_t*>(arg);
ASSERT_EQ(1024 * 1024, *rate_bytes_per_sec); ASSERT_EQ(1024 * 1024, *rate_bytes_per_sec);
}); });
// Block compaction // Block compaction
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBTest.LowPriWrite:0", "DBImpl::BGWorkCompaction"}, {"DBTest.LowPriWrite:0", "DBImpl::BGWorkCompaction"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo; WriteOptions wo;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
wo.low_pri = false; wo.low_pri = false;
@ -2835,7 +2837,7 @@ TEST_F(DBTest2, LowPriWrite) {
ASSERT_EQ(1, rate_limit_count.load()); ASSERT_EQ(1, rate_limit_count.load());
TEST_SYNC_POINT("DBTest.LowPriWrite:0"); TEST_SYNC_POINT("DBTest.LowPriWrite:0");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
wo.low_pri = true; wo.low_pri = true;
@ -3050,16 +3052,16 @@ TEST_F(DBTest2, LiveFilesOmitObsoleteFiles) {
// Instead, if we sleep for a second between Find and Purge, and ensure the // Instead, if we sleep for a second between Find and Purge, and ensure the
// read attempt happens after purge, then the sequence of events will almost // read attempt happens after purge, then the sequence of events will almost
// certainly happen on the old code. // certainly happen on the old code.
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBImpl::BackgroundCallFlush:FilesFound", {"DBImpl::BackgroundCallFlush:FilesFound",
"DBTest2::LiveFilesOmitObsoleteFiles:FlushTriggered"}, "DBTest2::LiveFilesOmitObsoleteFiles:FlushTriggered"},
{"DBImpl::PurgeObsoleteFiles:End", {"DBImpl::PurgeObsoleteFiles:End",
"DBTest2::LiveFilesOmitObsoleteFiles:LiveFilesCaptured"}, "DBTest2::LiveFilesOmitObsoleteFiles:LiveFilesCaptured"},
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::PurgeObsoleteFiles:Begin", "DBImpl::PurgeObsoleteFiles:Begin",
[&](void* /*arg*/) { env_->SleepForMicroseconds(1000000); }); [&](void* /*arg*/) { env_->SleepForMicroseconds(1000000); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("key", "val"); Put("key", "val");
FlushOptions flush_opts; FlushOptions flush_opts;
@ -3076,7 +3078,7 @@ TEST_F(DBTest2, LiveFilesOmitObsoleteFiles) {
} }
db_->EnableFileDeletions(); db_->EnableFileDeletions();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, TestNumPread) { TEST_F(DBTest2, TestNumPread) {
@ -3598,7 +3600,7 @@ TEST_F(DBTest2, PinnableSliceAndMmapReads) {
TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) { TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
BlockBasedTableOptions bbto; BlockBasedTableOptions bbto;
bbto.no_block_cache = false; bbto.no_block_cache = false;
bbto.cache_index_and_filter_blocks = false; bbto.cache_index_and_filter_blocks = false;
@ -3665,7 +3667,7 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
std::atomic<bool> finished(false); std::atomic<bool> finished(false);
std::atomic<int> block_newed(0); std::atomic<int> block_newed(0);
std::atomic<int> block_destroyed(0); std::atomic<int> block_destroyed(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Block::Block:0", [&](void* /*arg*/) { "Block::Block:0", [&](void* /*arg*/) {
if (finished) { if (finished) {
return; return;
@ -3675,7 +3677,7 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
EXPECT_LE(block_newed.load(), block_destroyed.load() + 1); EXPECT_LE(block_newed.load(), block_destroyed.load() + 1);
block_newed.fetch_add(1); block_newed.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"Block::~Block", [&](void* /*arg*/) { "Block::~Block", [&](void* /*arg*/) {
if (finished) { if (finished) {
return; return;
@ -3685,10 +3687,10 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
EXPECT_LE(block_newed.load(), block_destroyed.load() + 2); EXPECT_LE(block_newed.load(), block_destroyed.load() + 2);
block_destroyed.fetch_add(1); block_destroyed.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run:BeforeVerify", "CompactionJob::Run:BeforeVerify",
[&](void* /*arg*/) { finished = true; }); [&](void* /*arg*/) { finished = true; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr)); ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
@ -3696,21 +3698,21 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
ASSERT_EQ(8, block_newed.load()); ASSERT_EQ(8, block_newed.load());
ASSERT_EQ(8, block_destroyed.load()); ASSERT_EQ(8, block_destroyed.load());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBTest2, TestBBTTailPrefetch) { TEST_F(DBTest2, TestBBTTailPrefetch) {
std::atomic<bool> called(false); std::atomic<bool> called(false);
size_t expected_lower_bound = 512 * 1024; size_t expected_lower_bound = 512 * 1024;
size_t expected_higher_bound = 512 * 1024; size_t expected_higher_bound = 512 * 1024;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BlockBasedTable::Open::TailPrefetchLen", [&](void* arg) { "BlockBasedTable::Open::TailPrefetchLen", [&](void* arg) {
size_t* prefetch_size = static_cast<size_t*>(arg); size_t* prefetch_size = static_cast<size_t*>(arg);
EXPECT_LE(expected_lower_bound, *prefetch_size); EXPECT_LE(expected_lower_bound, *prefetch_size);
EXPECT_GE(expected_higher_bound, *prefetch_size); EXPECT_GE(expected_higher_bound, *prefetch_size);
called = true; called = true;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("1", "1"); Put("1", "1");
Put("9", "1"); Put("9", "1");
@ -3733,11 +3735,11 @@ TEST_F(DBTest2, TestBBTTailPrefetch) {
ASSERT_TRUE(called.load()); ASSERT_TRUE(called.load());
called = false; called = false;
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
std::atomic<bool> first_call(true); std::atomic<bool> first_call(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BlockBasedTable::Open::TailPrefetchLen", [&](void* arg) { "BlockBasedTable::Open::TailPrefetchLen", [&](void* arg) {
size_t* prefetch_size = static_cast<size_t*>(arg); size_t* prefetch_size = static_cast<size_t*>(arg);
if (first_call) { if (first_call) {
@ -3748,7 +3750,7 @@ TEST_F(DBTest2, TestBBTTailPrefetch) {
} }
called = true; called = true;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_file_opening_threads = 1; // one thread options.max_file_opening_threads = 1; // one thread
@ -3777,19 +3779,19 @@ TEST_F(DBTest2, TestBBTTailPrefetch) {
ASSERT_TRUE(called.load()); ASSERT_TRUE(called.load());
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
TEST_F(DBTest2, TestGetColumnFamilyHandleUnlocked) { TEST_F(DBTest2, TestGetColumnFamilyHandleUnlocked) {
// Setup sync point dependency to reproduce the race condition of // Setup sync point dependency to reproduce the race condition of
// DBImpl::GetColumnFamilyHandleUnlocked // DBImpl::GetColumnFamilyHandleUnlocked
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{ {"TestGetColumnFamilyHandleUnlocked::GetColumnFamilyHandleUnlocked1", {"TestGetColumnFamilyHandleUnlocked::GetColumnFamilyHandleUnlocked1",
"TestGetColumnFamilyHandleUnlocked::PreGetColumnFamilyHandleUnlocked2"}, "TestGetColumnFamilyHandleUnlocked::PreGetColumnFamilyHandleUnlocked2"},
{"TestGetColumnFamilyHandleUnlocked::GetColumnFamilyHandleUnlocked2", {"TestGetColumnFamilyHandleUnlocked::GetColumnFamilyHandleUnlocked2",
"TestGetColumnFamilyHandleUnlocked::ReadColumnFamilyHandle1"}, "TestGetColumnFamilyHandleUnlocked::ReadColumnFamilyHandle1"},
}); });
SyncPoint::GetInstance()->EnableProcessing(); SyncPoint::GetInstance()->EnableProcessing();
CreateColumnFamilies({"test1", "test2"}, Options()); CreateColumnFamilies({"test1", "test2"}, Options());
@ -3815,15 +3817,15 @@ TEST_F(DBTest2, TestGetColumnFamilyHandleUnlocked) {
user_thread1.join(); user_thread1.join();
user_thread2.join(); user_thread2.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
TEST_F(DBTest2, TestCompactFiles) { TEST_F(DBTest2, TestCompactFiles) {
// Setup sync point dependency to reproduce the race condition of // Setup sync point dependency to reproduce the race condition of
// DBImpl::GetColumnFamilyHandleUnlocked // DBImpl::GetColumnFamilyHandleUnlocked
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"TestCompactFiles::IngestExternalFile1", {"TestCompactFiles::IngestExternalFile1",
"TestCompactFiles::IngestExternalFile2"}, "TestCompactFiles::IngestExternalFile2"},
}); });
@ -3836,7 +3838,8 @@ TEST_F(DBTest2, TestCompactFiles) {
auto* handle = db_->DefaultColumnFamily(); auto* handle = db_->DefaultColumnFamily();
ASSERT_EQ(db_->NumberLevels(handle), 2); ASSERT_EQ(db_->NumberLevels(handle), 2);
rocksdb::SstFileWriter sst_file_writer{rocksdb::EnvOptions(), options}; ROCKSDB_NAMESPACE::SstFileWriter sst_file_writer{
ROCKSDB_NAMESPACE::EnvOptions(), options};
std::string external_file1 = dbname_ + "/test_compact_files1.sst_t"; std::string external_file1 = dbname_ + "/test_compact_files1.sst_t";
std::string external_file2 = dbname_ + "/test_compact_files2.sst_t"; std::string external_file2 = dbname_ + "/test_compact_files2.sst_t";
std::string external_file3 = dbname_ + "/test_compact_files3.sst_t"; std::string external_file3 = dbname_ + "/test_compact_files3.sst_t";
@ -3875,8 +3878,8 @@ TEST_F(DBTest2, TestCompactFiles) {
user_thread1.join(); user_thread1.join();
user_thread2.join(); user_thread2.join();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -3945,8 +3948,9 @@ class DummyOldStats : public Statistics {
void measureTime(uint32_t /*histogram_type*/, uint64_t /*count*/) override { void measureTime(uint32_t /*histogram_type*/, uint64_t /*count*/) override {
num_mt++; num_mt++;
} }
void histogramData(uint32_t /*histogram_type*/, void histogramData(
rocksdb::HistogramData* const /*data*/) const override {} uint32_t /*histogram_type*/,
ROCKSDB_NAMESPACE::HistogramData* const /*data*/) const override {}
std::string getHistogramString(uint32_t /*type*/) const override { std::string getHistogramString(uint32_t /*type*/) const override {
return ""; return "";
} }
@ -4066,7 +4070,7 @@ TEST_F(DBTest2, PrefixBloomFilteredOut) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
TEST_F(DBTest2, RowCacheSnapshot) { TEST_F(DBTest2, RowCacheSnapshot) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.row_cache = NewLRUCache(8 * 8192); options.row_cache = NewLRUCache(8 * 8192);
DestroyAndReopen(options); DestroyAndReopen(options);
@ -4159,14 +4163,14 @@ TEST_F(DBTest2, CrashInRecoveryMultipleCF) {
// Reopen and freeze the file system after the first manifest write. // Reopen and freeze the file system after the first manifest write.
FaultInjectionTestEnv fit_env(options.env); FaultInjectionTestEnv fit_env(options.env);
options.env = &fit_env; options.env = &fit_env;
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
test_sync_point, test_sync_point,
[&](void* /*arg*/) { fit_env.SetFilesystemActive(false); }); [&](void* /*arg*/) { fit_env.SetFilesystemActive(false); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_NOK(TryReopenWithColumnFamilies( ASSERT_NOK(TryReopenWithColumnFamilies(
{kDefaultColumnFamilyName, "pikachu"}, options)); {kDefaultColumnFamilyName, "pikachu"}, options));
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
fit_env.SetFilesystemActive(true); fit_env.SetFilesystemActive(true);
// If we continue using failure ingestion Env, it will conplain something // If we continue using failure ingestion Env, it will conplain something
@ -4213,7 +4217,8 @@ TEST_F(DBTest2, SeekFileRangeDeleteTail) {
TEST_F(DBTest2, BackgroundPurgeTest) { TEST_F(DBTest2, BackgroundPurgeTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.write_buffer_manager = std::make_shared<rocksdb::WriteBufferManager>(1 << 20); options.write_buffer_manager =
std::make_shared<ROCKSDB_NAMESPACE::WriteBufferManager>(1 << 20);
options.avoid_unnecessary_blocking_io = true; options.avoid_unnecessary_blocking_io = true;
DestroyAndReopen(options); DestroyAndReopen(options);
size_t base_value = options.write_buffer_manager->memory_usage(); size_t base_value = options.write_buffer_manager->memory_usage();
@ -4672,7 +4677,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
} }
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
extern "C" { extern "C" {
@ -4683,7 +4688,7 @@ void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
#endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
RegisterCustomObjects(argc, argv); RegisterCustomObjects(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -12,7 +12,7 @@
#include "rocksdb/env_encryption.h" #include "rocksdb/env_encryption.h"
#include "rocksdb/utilities/object_registry.h" #include "rocksdb/utilities/object_registry.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Special Env used to delay background operations // Special Env used to delay background operations
@ -90,9 +90,9 @@ DBTestBase::DBTestBase(const std::string path)
} }
DBTestBase::~DBTestBase() { DBTestBase::~DBTestBase() {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({}); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
Close(); Close();
Options options; Options options;
options.db_paths.emplace_back(dbname_, 0); options.db_paths.emplace_back(dbname_, 0);
@ -340,9 +340,10 @@ Options DBTestBase::GetOptions(
bool set_block_based_table_factory = true; bool set_block_based_table_factory = true;
#if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && \ #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && \
!defined(OS_AIX) !defined(OS_AIX)
rocksdb::SyncPoint::GetInstance()->ClearCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
"NewRandomAccessFile:O_DIRECT"); "NewRandomAccessFile:O_DIRECT");
rocksdb::SyncPoint::GetInstance()->ClearCallBack("NewWritableFile:O_DIRECT"); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
"NewWritableFile:O_DIRECT");
#endif #endif
bool can_allow_mmap = IsMemoryMappedAccessSupported(); bool can_allow_mmap = IsMemoryMappedAccessSupported();
@ -400,18 +401,18 @@ Options DBTestBase::GetOptions(
options.compaction_readahead_size = 2 * 1024 * 1024; options.compaction_readahead_size = 2 * 1024 * 1024;
#if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && \ #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && \
!defined(OS_AIX) && !defined(OS_OPENBSD) !defined(OS_AIX) && !defined(OS_OPENBSD)
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"NewWritableFile:O_DIRECT", [&](void* arg) { "NewWritableFile:O_DIRECT", [&](void* arg) {
int* val = static_cast<int*>(arg); int* val = static_cast<int*>(arg);
*val &= ~O_DIRECT; *val &= ~O_DIRECT;
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"NewRandomAccessFile:O_DIRECT", [&](void* arg) { "NewRandomAccessFile:O_DIRECT", [&](void* arg) {
int* val = static_cast<int*>(arg); int* val = static_cast<int*>(arg);
*val &= ~O_DIRECT; *val &= ~O_DIRECT;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
#endif #endif
break; break;
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -1560,4 +1561,4 @@ uint64_t DBTestBase::GetNumberOfSstFilesForColumnFamily(
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -52,7 +52,7 @@
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
namespace anon { namespace anon {
class AtomicCounter { class AtomicCounter {
@ -997,4 +997,4 @@ class DBTestBase : public testing::Test {
} }
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -13,7 +13,7 @@
#include "rocksdb/utilities/table_properties_collectors.h" #include "rocksdb/utilities/table_properties_collectors.h"
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static std::string CompressibleString(Random* rnd, int len) { static std::string CompressibleString(Random* rnd, int len) {
std::string r; std::string r;
@ -178,7 +178,7 @@ TEST_P(DBTestUniversalCompaction, OptimizeFiltersForHits) {
bbto.whole_key_filtering = true; bbto.whole_key_filtering = true;
options.table_factory.reset(NewBlockBasedTableFactory(bbto)); options.table_factory.reset(NewBlockBasedTableFactory(bbto));
options.optimize_filters_for_hits = true; options.optimize_filters_for_hits = true;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.memtable_factory.reset(new SpecialSkipListFactory(3)); options.memtable_factory.reset(new SpecialSkipListFactory(3));
DestroyAndReopen(options); DestroyAndReopen(options);
@ -249,7 +249,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) {
DestroyAndReopen(options); DestroyAndReopen(options);
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTestWritableFile.GetPreallocationStatus", [&](void* arg) { "DBTestWritableFile.GetPreallocationStatus", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
size_t preallocation_size = *(static_cast<size_t*>(arg)); size_t preallocation_size = *(static_cast<size_t*>(arg));
@ -257,7 +257,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) {
ASSERT_LE(preallocation_size, options.target_file_size_base * 1.1); ASSERT_LE(preallocation_size, options.target_file_size_base * 1.1);
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
int key_idx = 0; int key_idx = 0;
@ -335,7 +335,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) {
// All files at level 0 will be compacted into a single one. // All files at level 0 will be compacted into a single one.
ASSERT_EQ(NumSortedRuns(1), 1); ASSERT_EQ(NumSortedRuns(1), 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_P(DBTestUniversalCompaction, UniversalCompactionSizeAmplification) { TEST_P(DBTestUniversalCompaction, UniversalCompactionSizeAmplification) {
@ -395,7 +395,7 @@ TEST_P(DBTestUniversalCompaction, DynamicUniversalCompactionSizeAmplification) {
int total_picked_compactions = 0; int total_picked_compactions = 0;
int total_size_amp_compactions = 0; int total_size_amp_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) { "UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) {
if (arg) { if (arg) {
total_picked_compactions++; total_picked_compactions++;
@ -406,7 +406,7 @@ TEST_P(DBTestUniversalCompaction, DynamicUniversalCompactionSizeAmplification) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
MutableCFOptions mutable_cf_options; MutableCFOptions mutable_cf_options;
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -476,7 +476,7 @@ TEST_P(DBTestUniversalCompaction, DynamicUniversalCompactionReadAmplification) {
int total_picked_compactions = 0; int total_picked_compactions = 0;
int total_size_ratio_compactions = 0; int total_size_ratio_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) { "UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) {
if (arg) { if (arg) {
total_picked_compactions++; total_picked_compactions++;
@ -486,7 +486,7 @@ TEST_P(DBTestUniversalCompaction, DynamicUniversalCompactionReadAmplification) {
} }
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
MutableCFOptions mutable_cf_options; MutableCFOptions mutable_cf_options;
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
@ -704,17 +704,17 @@ TEST_P(DBTestUniversalCompactionMultiLevels, UniversalCompactionMultiLevels) {
TEST_P(DBTestUniversalCompactionMultiLevels, UniversalCompactionTrivialMove) { TEST_P(DBTestUniversalCompactionMultiLevels, UniversalCompactionTrivialMove) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) { "DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
non_trivial_move++; non_trivial_move++;
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
int output_level = *(static_cast<int*>(arg)); int output_level = *(static_cast<int*>(arg));
ASSERT_EQ(output_level, 0); ASSERT_EQ(output_level, 0);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
@ -745,7 +745,7 @@ TEST_P(DBTestUniversalCompactionMultiLevels, UniversalCompactionTrivialMove) {
ASSERT_GT(trivial_move, 0); ASSERT_GT(trivial_move, 0);
ASSERT_GT(non_trivial_move, 0); ASSERT_GT(non_trivial_move, 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
INSTANTIATE_TEST_CASE_P(MultiLevels, DBTestUniversalCompactionMultiLevels, INSTANTIATE_TEST_CASE_P(MultiLevels, DBTestUniversalCompactionMultiLevels,
@ -776,24 +776,24 @@ TEST_P(DBTestUniversalCompactionParallel, UniversalCompactionParallel) {
// Delay every compaction so multiple compactions will happen. // Delay every compaction so multiple compactions will happen.
std::atomic<int> num_compactions_running(0); std::atomic<int> num_compactions_running(0);
std::atomic<bool> has_parallel(false); std::atomic<bool> has_parallel(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack("CompactionJob::Run():Start", ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
[&](void* /*arg*/) { "CompactionJob::Run():Start", [&](void* /*arg*/) {
if (num_compactions_running.fetch_add(1) > 0) { if (num_compactions_running.fetch_add(1) > 0) {
has_parallel.store(true); has_parallel.store(true);
return; return;
} }
for (int nwait = 0; nwait < 20000; nwait++) { for (int nwait = 0; nwait < 20000; nwait++) {
if (has_parallel.load() || num_compactions_running.load() > 1) { if (has_parallel.load() || num_compactions_running.load() > 1) {
has_parallel.store(true); has_parallel.store(true);
break; break;
} }
env_->SleepForMicroseconds(1000); env_->SleepForMicroseconds(1000);
} }
}); });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():End", "CompactionJob::Run():End",
[&](void* /*arg*/) { num_compactions_running.fetch_add(-1); }); [&](void* /*arg*/) { num_compactions_running.fetch_add(-1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
options = CurrentOptions(options); options = CurrentOptions(options);
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
@ -805,7 +805,7 @@ TEST_P(DBTestUniversalCompactionParallel, UniversalCompactionParallel) {
} }
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(num_compactions_running.load(), 0); ASSERT_EQ(num_compactions_running.load(), 0);
ASSERT_TRUE(has_parallel.load()); ASSERT_TRUE(has_parallel.load());
@ -834,7 +834,7 @@ TEST_P(DBTestUniversalCompactionParallel, PickByFileNumberBug) {
UINT_MAX; UINT_MAX;
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBTestUniversalCompactionParallel::PickByFileNumberBug:0", {{"DBTestUniversalCompactionParallel::PickByFileNumberBug:0",
"BackgroundCallCompaction:0"}, "BackgroundCallCompaction:0"},
{"UniversalCompactionBuilder::PickCompaction:Return", {"UniversalCompactionBuilder::PickCompaction:Return",
@ -843,14 +843,14 @@ TEST_P(DBTestUniversalCompactionParallel, PickByFileNumberBug) {
"CompactionJob::Run():Start"}}); "CompactionJob::Run():Start"}});
int total_picked_compactions = 0; int total_picked_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) { "UniversalCompactionBuilder::PickCompaction:Return", [&](void* arg) {
if (arg) { if (arg) {
total_picked_compactions++; total_picked_compactions++;
} }
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Write 7 files to trigger compaction // Write 7 files to trigger compaction
int key_idx = 1; int key_idx = 1;
@ -865,7 +865,7 @@ TEST_P(DBTestUniversalCompactionParallel, PickByFileNumberBug) {
// Wait for the 1st background compaction process to start // Wait for the 1st background compaction process to start
TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:0"); TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:0");
TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:1"); TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:1");
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
// Write 3 files while 1st compaction is held // Write 3 files while 1st compaction is held
// These 3 files have different sizes to avoid compacting based on size_ratio // These 3 files have different sizes to avoid compacting based on size_ratio
@ -889,13 +889,13 @@ TEST_P(DBTestUniversalCompactionParallel, PickByFileNumberBug) {
EXPECT_EQ(TotalTableFiles(), 4); EXPECT_EQ(TotalTableFiles(), 4);
// Stop SyncPoint and destroy the DB and reopen it again // Stop SyncPoint and destroy the DB and reopen it again
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
key_idx = 1; key_idx = 1;
total_picked_compactions = 0; total_picked_compactions = 0;
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Write 7 files to trigger compaction // Write 7 files to trigger compaction
for (int i = 1; i <= 70; i++) { for (int i = 1; i <= 70; i++) {
@ -909,7 +909,7 @@ TEST_P(DBTestUniversalCompactionParallel, PickByFileNumberBug) {
// Wait for the 1st background compaction process to start // Wait for the 1st background compaction process to start
TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:0"); TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:0");
TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:1"); TEST_SYNC_POINT("DBTestUniversalCompactionParallel::PickByFileNumberBug:1");
rocksdb::SyncPoint::GetInstance()->ClearTrace(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
// Write 8 files while 1st compaction is held // Write 8 files while 1st compaction is held
// These 8 files have different sizes to avoid compacting based on size_ratio // These 8 files have different sizes to avoid compacting based on size_ratio
@ -1161,17 +1161,17 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionCompressRatio2) {
TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest1) { TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest1) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
int32_t non_trivial_move = 0; int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) { "DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
non_trivial_move++; non_trivial_move++;
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
int output_level = *(static_cast<int*>(arg)); int output_level = *(static_cast<int*>(arg));
ASSERT_EQ(output_level, 0); ASSERT_EQ(output_level, 0);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
@ -1202,22 +1202,22 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest1) {
ASSERT_GT(trivial_move, 0); ASSERT_GT(trivial_move, 0);
ASSERT_GT(non_trivial_move, 0); ASSERT_GT(non_trivial_move, 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
// Test that checks trivial move in universal compaction // Test that checks trivial move in universal compaction
TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest2) { TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest2) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove", "DBImpl::BackgroundCompaction:TrivialMove",
[&](void* /*arg*/) { trivial_move++; }); [&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) { "DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
int output_level = *(static_cast<int*>(arg)); int output_level = *(static_cast<int*>(arg));
ASSERT_EQ(output_level, 0); ASSERT_EQ(output_level, 0);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
@ -1247,7 +1247,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest2) {
ASSERT_GT(trivial_move, 0); ASSERT_GT(trivial_move, 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif // ROCKSDB_VALGRIND_RUN #endif // ROCKSDB_VALGRIND_RUN
@ -1708,7 +1708,7 @@ TEST_P(DBTestUniversalCompaction, ConcurrentBottomPriLowPriCompactions) {
options.compaction_options_universal.max_size_amplification_percent = 110; options.compaction_options_universal.max_size_amplification_percent = 110;
DestroyAndReopen(options); DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{// wait for the full compaction to be picked before adding files intended {// wait for the full compaction to be picked before adding files intended
// for the second one. // for the second one.
{"DBImpl::BackgroundCompaction:ForwardToBottomPriPool", {"DBImpl::BackgroundCompaction:ForwardToBottomPriPool",
@ -1741,7 +1741,7 @@ TEST_P(DBTestUniversalCompaction, ConcurrentBottomPriLowPriCompactions) {
ASSERT_EQ(NumSortedRuns(), 2); ASSERT_EQ(NumSortedRuns(), 2);
ASSERT_GT(NumTableFilesAtLevel(0), 0); ASSERT_GT(NumTableFilesAtLevel(0), 0);
ASSERT_GT(NumTableFilesAtLevel(num_levels_ - 1), 0); ASSERT_GT(NumTableFilesAtLevel(num_levels_ - 1), 0);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
Env::Default()->SetBackgroundThreads(0, Env::Priority::BOTTOM); Env::Default()->SetBackgroundThreads(0, Env::Priority::BOTTOM);
} }
@ -1762,11 +1762,10 @@ TEST_P(DBTestUniversalCompaction, RecalculateScoreAfterPicking) {
Reopen(options); Reopen(options);
std::atomic<int> num_compactions_attempted(0); std::atomic<int> num_compactions_attempted(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:Start", [&](void* /*arg*/) { "DBImpl::BackgroundCompaction:Start",
++num_compactions_attempted; [&](void* /*arg*/) { ++num_compactions_attempted; });
}); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301); Random rnd(301);
for (int num = 0; num < kNumFilesTrigger; num++) { for (int num = 0; num < kNumFilesTrigger; num++) {
@ -1815,12 +1814,12 @@ TEST_P(DBTestUniversalCompaction, FinalSortedRunCompactFilesConflict) {
std::string first_sst_filename = std::string first_sst_filename =
cf_meta.levels[num_levels_ - 1].files[0].name; cf_meta.levels[num_levels_ - 1].files[0].name;
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"CompactFilesImpl:0", {{"CompactFilesImpl:0",
"DBTestUniversalCompaction:FinalSortedRunCompactFilesConflict:0"}, "DBTestUniversalCompaction:FinalSortedRunCompactFilesConflict:0"},
{"DBImpl::BackgroundCompaction():AfterPickCompaction", {"DBImpl::BackgroundCompaction():AfterPickCompaction",
"CompactFilesImpl:1"}}); "CompactFilesImpl:1"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
port::Thread compact_files_thread([&]() { port::Thread compact_files_thread([&]() {
ASSERT_OK(dbfull()->CompactFiles(CompactionOptions(), default_cfh, ASSERT_OK(dbfull()->CompactFiles(CompactionOptions(), default_cfh,
@ -2189,7 +2188,7 @@ TEST_F(DBTestUniversalCompaction2, PeriodicCompaction) {
int periodic_compactions = 0; int periodic_compactions = 0;
int start_level = -1; int start_level = -1;
int output_level = -1; int output_level = -1;
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"UniversalCompactionPicker::PickPeriodicCompaction:Return", "UniversalCompactionPicker::PickPeriodicCompaction:Return",
[&](void* arg) { [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg); Compaction* compaction = reinterpret_cast<Compaction*>(arg);
@ -2200,7 +2199,7 @@ TEST_F(DBTestUniversalCompaction2, PeriodicCompaction) {
output_level = compaction->output_level(); output_level = compaction->output_level();
periodic_compactions++; periodic_compactions++;
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Case 1: Oldest flushed file excceeds periodic compaction threshold. // Case 1: Oldest flushed file excceeds periodic compaction threshold.
ASSERT_OK(Put("foo", "bar")); ASSERT_OK(Put("foo", "bar"));
@ -2238,13 +2237,13 @@ TEST_F(DBTestUniversalCompaction2, PeriodicCompaction) {
ASSERT_EQ(4, output_level); ASSERT_EQ(4, output_level);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#endif // !defined(ROCKSDB_LITE) #endif // !defined(ROCKSDB_LITE)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else #else

View File

@ -15,7 +15,7 @@
#include "test_util/fault_injection_test_env.h" #include "test_util/fault_injection_test_env.h"
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DBWALTest : public DBTestBase { class DBWALTest : public DBTestBase {
public: public:
DBWALTest() : DBTestBase("/db_wal_test") {} DBWALTest() : DBTestBase("/db_wal_test") {}
@ -191,15 +191,15 @@ TEST_F(DBWALTest, SyncWALNotBlockWrite) {
ASSERT_OK(Put("foo1", "bar1")); ASSERT_OK(Put("foo1", "bar1"));
ASSERT_OK(Put("foo5", "bar5")); ASSERT_OK(Put("foo5", "bar5"));
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"WritableFileWriter::SyncWithoutFlush:1", {"WritableFileWriter::SyncWithoutFlush:1",
"DBWALTest::SyncWALNotBlockWrite:1"}, "DBWALTest::SyncWALNotBlockWrite:1"},
{"DBWALTest::SyncWALNotBlockWrite:2", {"DBWALTest::SyncWALNotBlockWrite:2",
"WritableFileWriter::SyncWithoutFlush:2"}, "WritableFileWriter::SyncWithoutFlush:2"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([&]() { ASSERT_OK(db_->SyncWAL()); }); ROCKSDB_NAMESPACE::port::Thread thread([&]() { ASSERT_OK(db_->SyncWAL()); });
TEST_SYNC_POINT("DBWALTest::SyncWALNotBlockWrite:1"); TEST_SYNC_POINT("DBWALTest::SyncWALNotBlockWrite:1");
ASSERT_OK(Put("foo2", "bar2")); ASSERT_OK(Put("foo2", "bar2"));
@ -218,20 +218,21 @@ TEST_F(DBWALTest, SyncWALNotBlockWrite) {
ASSERT_EQ(Get("foo3"), "bar3"); ASSERT_EQ(Get("foo3"), "bar3");
ASSERT_EQ(Get("foo4"), "bar4"); ASSERT_EQ(Get("foo4"), "bar4");
ASSERT_EQ(Get("foo5"), "bar5"); ASSERT_EQ(Get("foo5"), "bar5");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBWALTest, SyncWALNotWaitWrite) { TEST_F(DBWALTest, SyncWALNotWaitWrite) {
ASSERT_OK(Put("foo1", "bar1")); ASSERT_OK(Put("foo1", "bar1"));
ASSERT_OK(Put("foo3", "bar3")); ASSERT_OK(Put("foo3", "bar3"));
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"SpecialEnv::WalFile::Append:1", "DBWALTest::SyncWALNotWaitWrite:1"}, {"SpecialEnv::WalFile::Append:1", "DBWALTest::SyncWALNotWaitWrite:1"},
{"DBWALTest::SyncWALNotWaitWrite:2", "SpecialEnv::WalFile::Append:2"}, {"DBWALTest::SyncWALNotWaitWrite:2", "SpecialEnv::WalFile::Append:2"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([&]() { ASSERT_OK(Put("foo2", "bar2")); }); ROCKSDB_NAMESPACE::port::Thread thread(
[&]() { ASSERT_OK(Put("foo2", "bar2")); });
// Moving this to SyncWAL before the actual fsync // Moving this to SyncWAL before the actual fsync
// TEST_SYNC_POINT("DBWALTest::SyncWALNotWaitWrite:1"); // TEST_SYNC_POINT("DBWALTest::SyncWALNotWaitWrite:1");
ASSERT_OK(db_->SyncWAL()); ASSERT_OK(db_->SyncWAL());
@ -242,7 +243,7 @@ TEST_F(DBWALTest, SyncWALNotWaitWrite) {
ASSERT_EQ(Get("foo1"), "bar1"); ASSERT_EQ(Get("foo1"), "bar1");
ASSERT_EQ(Get("foo2"), "bar2"); ASSERT_EQ(Get("foo2"), "bar2");
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBWALTest, Recover) { TEST_F(DBWALTest, Recover) {
@ -293,7 +294,7 @@ TEST_F(DBWALTest, RecoverWithTableHandle) {
// happen. // happen.
options.max_open_files = kSmallMaxOpenFiles; options.max_open_files = kSmallMaxOpenFiles;
// RocksDB sanitize max open files to at least 20. Modify it back. // RocksDB sanitize max open files to at least 20. Modify it back.
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) { "SanitizeOptions::AfterChangeMaxOpenFiles", [&](void* arg) {
int* max_open_files = static_cast<int*>(arg); int* max_open_files = static_cast<int*>(arg);
*max_open_files = kSmallMaxOpenFiles; *max_open_files = kSmallMaxOpenFiles;
@ -305,10 +306,10 @@ TEST_F(DBWALTest, RecoverWithTableHandle) {
} else { } else {
options.max_open_files = -1; options.max_open_files = -1;
} }
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ReopenWithColumnFamilies({"default", "pikachu"}, options); ReopenWithColumnFamilies({"default", "pikachu"}, options);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
std::vector<std::vector<FileMetaData>> files; std::vector<std::vector<FileMetaData>> files;
dbfull()->TEST_GetFilesMetaData(handles_[1], &files); dbfull()->TEST_GetFilesMetaData(handles_[1], &files);
@ -443,38 +444,38 @@ TEST_F(DBWALTest, PreallocateBlock) {
DestroyAndReopen(options); DestroyAndReopen(options);
std::atomic<int> called(0); std::atomic<int> called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTestWalFile.GetPreallocationStatus", [&](void* arg) { "DBTestWalFile.GetPreallocationStatus", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
size_t preallocation_size = *(static_cast<size_t*>(arg)); size_t preallocation_size = *(static_cast<size_t*>(arg));
ASSERT_EQ(expected_preallocation_size, preallocation_size); ASSERT_EQ(expected_preallocation_size, preallocation_size);
called.fetch_add(1); called.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("", ""); Put("", "");
Flush(); Flush();
Put("", ""); Put("", "");
Close(); Close();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(2, called.load()); ASSERT_EQ(2, called.load());
options.max_total_wal_size = 1000 * 1000; options.max_total_wal_size = 1000 * 1000;
expected_preallocation_size = static_cast<size_t>(options.max_total_wal_size); expected_preallocation_size = static_cast<size_t>(options.max_total_wal_size);
Reopen(options); Reopen(options);
called.store(0); called.store(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTestWalFile.GetPreallocationStatus", [&](void* arg) { "DBTestWalFile.GetPreallocationStatus", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
size_t preallocation_size = *(static_cast<size_t*>(arg)); size_t preallocation_size = *(static_cast<size_t*>(arg));
ASSERT_EQ(expected_preallocation_size, preallocation_size); ASSERT_EQ(expected_preallocation_size, preallocation_size);
called.fetch_add(1); called.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("", ""); Put("", "");
Flush(); Flush();
Put("", ""); Put("", "");
Close(); Close();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(2, called.load()); ASSERT_EQ(2, called.load());
options.db_write_buffer_size = 800 * 1000; options.db_write_buffer_size = 800 * 1000;
@ -482,19 +483,19 @@ TEST_F(DBWALTest, PreallocateBlock) {
static_cast<size_t>(options.db_write_buffer_size); static_cast<size_t>(options.db_write_buffer_size);
Reopen(options); Reopen(options);
called.store(0); called.store(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTestWalFile.GetPreallocationStatus", [&](void* arg) { "DBTestWalFile.GetPreallocationStatus", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
size_t preallocation_size = *(static_cast<size_t*>(arg)); size_t preallocation_size = *(static_cast<size_t*>(arg));
ASSERT_EQ(expected_preallocation_size, preallocation_size); ASSERT_EQ(expected_preallocation_size, preallocation_size);
called.fetch_add(1); called.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("", ""); Put("", "");
Flush(); Flush();
Put("", ""); Put("", "");
Close(); Close();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(2, called.load()); ASSERT_EQ(2, called.load());
expected_preallocation_size = 700 * 1000; expected_preallocation_size = 700 * 1000;
@ -503,19 +504,19 @@ TEST_F(DBWALTest, PreallocateBlock) {
options.write_buffer_manager = write_buffer_manager; options.write_buffer_manager = write_buffer_manager;
Reopen(options); Reopen(options);
called.store(0); called.store(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"DBTestWalFile.GetPreallocationStatus", [&](void* arg) { "DBTestWalFile.GetPreallocationStatus", [&](void* arg) {
ASSERT_TRUE(arg != nullptr); ASSERT_TRUE(arg != nullptr);
size_t preallocation_size = *(static_cast<size_t*>(arg)); size_t preallocation_size = *(static_cast<size_t*>(arg));
ASSERT_EQ(expected_preallocation_size, preallocation_size); ASSERT_EQ(expected_preallocation_size, preallocation_size);
called.fetch_add(1); called.fetch_add(1);
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Put("", ""); Put("", "");
Flush(); Flush();
Put("", ""); Put("", "");
Close(); Close();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
ASSERT_EQ(2, called.load()); ASSERT_EQ(2, called.load());
} }
#endif // !(defined NDEBUG) || !defined(OS_WIN) #endif // !(defined NDEBUG) || !defined(OS_WIN)
@ -577,19 +578,19 @@ TEST_F(DBWALTest, FullPurgePreservesLogPendingReuse) {
// The second flush can recycle the first log. Sync points enforce the // The second flush can recycle the first log. Sync points enforce the
// full purge happens after choosing the log to recycle and before it is // full purge happens after choosing the log to recycle and before it is
// renamed. // renamed.
rocksdb::SyncPoint::GetInstance()->LoadDependency({ ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
{"DBImpl::CreateWAL:BeforeReuseWritableFile1", {"DBImpl::CreateWAL:BeforeReuseWritableFile1",
"DBWALTest::FullPurgePreservesLogPendingReuse:PreFullPurge"}, "DBWALTest::FullPurgePreservesLogPendingReuse:PreFullPurge"},
{"DBWALTest::FullPurgePreservesLogPendingReuse:PostFullPurge", {"DBWALTest::FullPurgePreservesLogPendingReuse:PostFullPurge",
"DBImpl::CreateWAL:BeforeReuseWritableFile2"}, "DBImpl::CreateWAL:BeforeReuseWritableFile2"},
}); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
rocksdb::port::Thread thread([&]() { ROCKSDB_NAMESPACE::port::Thread thread([&]() {
TEST_SYNC_POINT( TEST_SYNC_POINT(
"DBWALTest::FullPurgePreservesLogPendingReuse:PreFullPurge"); "DBWALTest::FullPurgePreservesLogPendingReuse:PreFullPurge");
ASSERT_OK(db_->EnableFileDeletions(true)); ASSERT_OK(db_->EnableFileDeletions(true));
TEST_SYNC_POINT( TEST_SYNC_POINT(
"DBWALTest::FullPurgePreservesLogPendingReuse:PostFullPurge"); "DBWALTest::FullPurgePreservesLogPendingReuse:PostFullPurge");
}); });
ASSERT_OK(Put("foo", "bar")); ASSERT_OK(Put("foo", "bar"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -1576,10 +1577,10 @@ TEST_F(DBWALTest, WalTermTest) {
ASSERT_EQ("bar", Get(1, "foo")); ASSERT_EQ("bar", Get(1, "foo"));
ASSERT_EQ("NOT_FOUND", Get(1, "foo2")); ASSERT_EQ("NOT_FOUND", Get(1, "foo2"));
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -17,7 +17,7 @@
#include "test_util/sync_point.h" #include "test_util/sync_point.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Test variations of WriteImpl. // Test variations of WriteImpl.
class DBWriteTest : public DBTestBase, public testing::WithParamInterface<int> { class DBWriteTest : public DBTestBase, public testing::WithParamInterface<int> {
@ -79,18 +79,18 @@ TEST_P(DBWriteTest, WriteThreadHangOnWriteStall) {
Flush(); Flush();
Put("foo" + std::to_string(thread_num.fetch_add(1)), "bar"); Put("foo" + std::to_string(thread_num.fetch_add(1)), "bar");
rocksdb::SyncPoint::GetInstance()->SetCallBack( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WriteThread::JoinBatchGroup:Start", unblock_main_thread_func); "WriteThread::JoinBatchGroup:Start", unblock_main_thread_func);
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBWriteTest::WriteThreadHangOnWriteStall:1", {{"DBWriteTest::WriteThreadHangOnWriteStall:1",
"DBImpl::BackgroundCallFlush:start"}, "DBImpl::BackgroundCallFlush:start"},
{"DBWriteTest::WriteThreadHangOnWriteStall:2", {"DBWriteTest::WriteThreadHangOnWriteStall:2",
"DBImpl::WriteImpl:BeforeLeaderEnters"}, "DBImpl::WriteImpl:BeforeLeaderEnters"},
// Make compaction start wait for the write stall to be detected and // Make compaction start wait for the write stall to be detected and
// implemented by a write group leader // implemented by a write group leader
{"DBWriteTest::WriteThreadHangOnWriteStall:3", {"DBWriteTest::WriteThreadHangOnWriteStall:3",
"BackgroundCallCompaction:0"}}); "BackgroundCallCompaction:0"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Schedule creation of 4th L0 file without waiting. This will seal the // Schedule creation of 4th L0 file without waiting. This will seal the
// memtable and then wait for a sync point before writing the file. We need // memtable and then wait for a sync point before writing the file. We need
@ -279,7 +279,7 @@ TEST_P(DBWriteTest, LockWalInEffect) {
TEST_P(DBWriteTest, ConcurrentlyDisabledWAL) { TEST_P(DBWriteTest, ConcurrentlyDisabledWAL) {
Options options = GetOptions(); Options options = GetOptions();
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
options.statistics->set_stats_level(StatsLevel::kAll); options.statistics->set_stats_level(StatsLevel::kAll);
Reopen(options); Reopen(options);
std::string wal_key_prefix = "WAL_KEY_"; std::string wal_key_prefix = "WAL_KEY_";
@ -292,14 +292,16 @@ TEST_P(DBWriteTest, ConcurrentlyDisabledWAL) {
for (int t = 0; t < 10; t++) { for (int t = 0; t < 10; t++) {
threads[t] = std::thread([t, wal_key_prefix, wal_value, no_wal_key_prefix, no_wal_value, this] { threads[t] = std::thread([t, wal_key_prefix, wal_value, no_wal_key_prefix, no_wal_value, this] {
for(int i = 0; i < 10; i++) { for(int i = 0; i < 10; i++) {
rocksdb::WriteOptions write_option_disable; ROCKSDB_NAMESPACE::WriteOptions write_option_disable;
write_option_disable.disableWAL = true; write_option_disable.disableWAL = true;
rocksdb::WriteOptions write_option_default; ROCKSDB_NAMESPACE::WriteOptions write_option_default;
std::string no_wal_key = no_wal_key_prefix + std::to_string(t) + "_" + std::to_string(i); std::string no_wal_key = no_wal_key_prefix + std::to_string(t) +
this->Put(no_wal_key, no_wal_value, write_option_disable); "_" + std::to_string(i);
std::string wal_key = wal_key_prefix + std::to_string(i) + "_" + std::to_string(i); this->Put(no_wal_key, no_wal_value, write_option_disable);
this->Put(wal_key, wal_value, write_option_default); std::string wal_key =
dbfull()->SyncWAL(); wal_key_prefix + std::to_string(i) + "_" + std::to_string(i);
this->Put(wal_key, wal_value, write_option_default);
dbfull()->SyncWAL();
} }
return 0; return 0;
}); });
@ -307,7 +309,8 @@ TEST_P(DBWriteTest, ConcurrentlyDisabledWAL) {
for (auto& t: threads) { for (auto& t: threads) {
t.join(); t.join();
} }
uint64_t bytes_num = options.statistics->getTickerCount(rocksdb::Tickers::WAL_FILE_BYTES); uint64_t bytes_num = options.statistics->getTickerCount(
ROCKSDB_NAMESPACE::Tickers::WAL_FILE_BYTES);
// written WAL size should less than 100KB (even included HEADER & FOOTER overhead) // written WAL size should less than 100KB (even included HEADER & FOOTER overhead)
ASSERT_LE(bytes_num, 1024 * 100); ASSERT_LE(bytes_num, 1024 * 100);
} }
@ -317,10 +320,10 @@ INSTANTIATE_TEST_CASE_P(DBWriteTestInstance, DBWriteTest,
DBTestBase::kConcurrentWALWrites, DBTestBase::kConcurrentWALWrites,
DBTestBase::kPipelinedWrite)); DBTestBase::kPipelinedWrite));
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@ -15,7 +15,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// kValueTypeForSeek defines the ValueType that should be passed when // kValueTypeForSeek defines the ValueType that should be passed when
// constructing a ParsedInternalKey object for seeking to a particular // constructing a ParsedInternalKey object for seeking to a particular
@ -194,4 +194,4 @@ void IterKey::EnlargeBuffer(size_t key_size) {
buf_ = new char[key_size]; buf_ = new char[key_size];
buf_size_ = key_size; buf_size_ = key_size;
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -26,7 +26,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/user_comparator_wrapper.h" #include "util/user_comparator_wrapper.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// The file declares data structures and functions that deal with internal // The file declares data structures and functions that deal with internal
// keys. // keys.
@ -668,4 +668,4 @@ struct ParsedInternalKeyComparator {
const InternalKeyComparator* cmp; const InternalKeyComparator* cmp;
}; };
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE

View File

@ -11,7 +11,7 @@
#include "logging/logging.h" #include "logging/logging.h"
#include "test_util/testharness.h" #include "test_util/testharness.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
static std::string IKey(const std::string& user_key, static std::string IKey(const std::string& user_key,
uint64_t seq, uint64_t seq,
@ -199,7 +199,7 @@ TEST_F(FormatTest, RangeTombstoneSerializeEndKey) {
ASSERT_LT(cmp.Compare(t.SerializeEndKey(), k), 0); ASSERT_LT(cmp.Compare(t.SerializeEndKey(), k), 0);
} }
} // namespace rocksdb } // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);

View File

@ -27,7 +27,7 @@
#include "test_util/testutil.h" #include "test_util/testutil.h"
#include "util/string_util.h" #include "util/string_util.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
class DeleteFileTest : public DBTestBase { class DeleteFileTest : public DBTestBase {
public: public:
@ -388,13 +388,13 @@ TEST_F(DeleteFileTest, BackgroundPurgeTestMultipleJobs) {
// 5 sst files after 2 compactions with 2 live iterators // 5 sst files after 2 compactions with 2 live iterators
CheckFileTypeCounts(dbname_, 0, 5, 1); CheckFileTypeCounts(dbname_, 0, 5, 1);
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
// ~DBImpl should wait until all BGWorkPurge are finished // ~DBImpl should wait until all BGWorkPurge are finished
rocksdb::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::~DBImpl:WaitJob", "DBImpl::BGWorkPurge"}, {{"DBImpl::~DBImpl:WaitJob", "DBImpl::BGWorkPurge"},
{"DeleteFileTest::GuardFinish", {"DeleteFileTest::GuardFinish",
"DeleteFileTest::BackgroundPurgeTestMultipleJobs:DBClose"}}); "DeleteFileTest::BackgroundPurgeTestMultipleJobs:DBClose"}});
rocksdb::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
delete itr1; delete itr1;
env_->Schedule(&DeleteFileTest::DoSleep, this, Env::Priority::HIGH); env_->Schedule(&DeleteFileTest::DoSleep, this, Env::Priority::HIGH);
@ -542,7 +542,7 @@ TEST_F(DeleteFileTest, DeleteNonDefaultColumnFamily) {
} }
} }
} //namespace rocksdb } // namespace ROCKSDB_NAMESPACE
#ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
extern "C" { extern "C" {
@ -553,7 +553,7 @@ void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
#endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
int main(int argc, char** argv) { int main(int argc, char** argv) {
rocksdb::port::InstallStackTraceHandler(); ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
RegisterCustomObjects(argc, argv); RegisterCustomObjects(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -8,7 +8,7 @@
#include "db/event_helpers.h" #include "db/event_helpers.h"
#include "file/sst_file_manager_impl.h" #include "file/sst_file_manager_impl.h"
namespace rocksdb { namespace ROCKSDB_NAMESPACE {
// Maps to help decide the severity of an error based on the // Maps to help decide the severity of an error based on the
// BackgroundErrorReason, Code, SubCode and whether db_options.paranoid_checks // BackgroundErrorReason, Code, SubCode and whether db_options.paranoid_checks
@ -341,4 +341,4 @@ Status ErrorHandler::RecoverFromBGError(bool is_manual) {
return bg_error_; return bg_error_;
#endif #endif
} }
} } // namespace ROCKSDB_NAMESPACE

Some files were not shown because too many files have changed in this diff Show More