From a177742a9b965f5be72a1457465b1b8ce0413d12 Mon Sep 17 00:00:00 2001 From: sdong Date: Wed, 12 Nov 2014 13:05:12 -0800 Subject: [PATCH] Make db_stress built for ROCKSDB_LITE Summary: Make db_stress built for ROCKSDB_LITE. The test doesn't pass tough. It seg fault quickly. But I took a look and it doesn't seem to be related to lite version. Likely to be a bug inside RocksDB. Test Plan: make db_stress Reviewers: yhchiang, rven, ljin, igor Reviewed By: igor Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D28797 --- db/db_bench.cc | 24 ++++++++++++++++++++---- db/perf_context_test.cc | 5 +++++ table/table_reader_bench.cc | 10 ++++++++++ tools/blob_store_bench.cc | 8 ++++++++ tools/db_repl_stress.cc | 9 +++++++++ tools/db_sanity_test.cc | 7 +++++-- tools/db_stress.cc | 19 ++++++++++++++++--- tools/ldb.cc | 8 ++++++++ tools/sst_dump.cc | 8 ++++++++ util/sst_dump_tool.cc | 3 +-- 10 files changed, 90 insertions(+), 11 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index c66a1fc1c..54ede5161 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -1878,14 +1878,15 @@ class Benchmark { exit(1); } switch (FLAGS_rep_factory) { - case kPrefixHash: - options.memtable_factory.reset(NewHashSkipListRepFactory( - FLAGS_hash_bucket_count)); - break; case kSkipList: options.memtable_factory.reset(new SkipListFactory( FLAGS_skip_list_lookahead)); break; +#ifndef ROCKSDB_LITE + case kPrefixHash: + options.memtable_factory.reset( + NewHashSkipListRepFactory(FLAGS_hash_bucket_count)); + break; case kHashLinkedList: options.memtable_factory.reset(NewHashLinkListRepFactory( FLAGS_hash_bucket_count)); @@ -1899,8 +1900,14 @@ class Benchmark { options.memtable_factory.reset(NewHashCuckooRepFactory( options.write_buffer_size, FLAGS_key_size + FLAGS_value_size)); break; +#else + default: + fprintf(stderr, "Only skip list is supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } if (FLAGS_use_plain_table) { +#ifndef ROCKSDB_LITE if (FLAGS_rep_factory != kPrefixHash && FLAGS_rep_factory != kHashLinkedList) { fprintf(stderr, "Waring: plain table is used with skipList\n"); @@ -1921,7 +1928,12 @@ class Benchmark { plain_table_options.hash_table_ratio = 0.75; options.table_factory = std::shared_ptr( NewPlainTableFactory(plain_table_options)); +#else + fprintf(stderr, "Plain table is not supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } else if (FLAGS_use_cuckoo_table) { +#ifndef ROCKSDB_LITE if (FLAGS_cuckoo_hash_ratio > 1 || FLAGS_cuckoo_hash_ratio < 0) { fprintf(stderr, "Invalid cuckoo_hash_ratio\n"); exit(1); @@ -1931,6 +1943,10 @@ class Benchmark { table_options.identity_as_first_hash = FLAGS_identity_as_first_hash; options.table_factory = std::shared_ptr( NewCuckooTableFactory(table_options)); +#else + fprintf(stderr, "Cuckoo table is not supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } else { BlockBasedTableOptions block_based_options; if (FLAGS_use_hash_search) { diff --git a/db/perf_context_test.cc b/db/perf_context_test.cc index 6669aaec3..2d20a0186 100644 --- a/db/perf_context_test.cc +++ b/db/perf_context_test.cc @@ -38,8 +38,13 @@ std::shared_ptr OpenDb(bool read_only = false) { FLAGS_min_write_buffer_number_to_merge; if (FLAGS_use_set_based_memetable) { +#ifndef ROCKSDB_LITE options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(0)); options.memtable_factory.reset(NewHashSkipListRepFactory()); +#else + fprintf(stderr, "Prefix hash is not supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } Status s; diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index ea722a8bf..a75424e82 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -257,12 +257,18 @@ int main(int argc, char** argv) { options.compression = rocksdb::CompressionType::kNoCompression; if (FLAGS_table_factory == "cuckoo_hash") { +#ifndef ROCKSDB_LITE options.allow_mmap_reads = true; env_options.use_mmap_reads = true; rocksdb::CuckooTableOptions table_options; table_options.hash_table_ratio = 0.75; tf.reset(rocksdb::NewCuckooTableFactory(table_options)); +#else + fprintf(stderr, "Plain table is not supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } else if (FLAGS_table_factory == "plain_table") { +#ifndef ROCKSDB_LITE options.allow_mmap_reads = true; env_options.use_mmap_reads = true; @@ -274,6 +280,10 @@ int main(int argc, char** argv) { tf.reset(new rocksdb::PlainTableFactory(plain_table_options)); options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform( FLAGS_prefix_len)); +#else + fprintf(stderr, "Cuckoo table is not supported in lite mode\n"); + exit(1); +#endif // ROCKSDB_LITE } else if (FLAGS_table_factory == "block_based") { tf.reset(new rocksdb::BlockBasedTableFactory()); } else { diff --git a/tools/blob_store_bench.cc b/tools/blob_store_bench.cc index 99ca66a37..0daae1a11 100644 --- a/tools/blob_store_bench.cc +++ b/tools/blob_store_bench.cc @@ -3,6 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. +#ifndef ROCKSDB_LITE #include #include #include @@ -282,3 +283,10 @@ int main(int argc, const char** argv) { return 0; } +#else // ROCKSDB_LITE +#include +int main(int argc, char** argv) { + fprintf(stderr, "Not supported in lite mode.\n"); + return 1; +} +#endif // ROCKSDB_LITE diff --git a/tools/db_repl_stress.cc b/tools/db_repl_stress.cc index ec18ab512..b745d7b37 100644 --- a/tools/db_repl_stress.cc +++ b/tools/db_repl_stress.cc @@ -3,6 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. +#ifndef ROCKSDB_LITE #ifndef GFLAGS #include int main() { @@ -145,3 +146,11 @@ int main(int argc, const char** argv) { } #endif // GFLAGS + +#else // ROCKSDB_LITE +#include +int main(int argc, char** argv) { + fprintf(stderr, "Not supported in lite mode.\n"); + return 1; +} +#endif // ROCKSDB_LITE diff --git a/tools/db_sanity_test.cc b/tools/db_sanity_test.cc index 237ef07d0..f994ab38b 100644 --- a/tools/db_sanity_test.cc +++ b/tools/db_sanity_test.cc @@ -131,6 +131,7 @@ class SanityTestZlibCompression : public SanityTest { Options options_; }; +#ifndef ROCKSDB_LITE class SanityTestPlainTableFactory : public SanityTest { public: explicit SanityTestPlainTableFactory(const std::string& path) @@ -146,6 +147,7 @@ class SanityTestPlainTableFactory : public SanityTest { private: Options options_; }; +#endif // ROCKSDB_LITE class SanityTestBloomFilter : public SanityTest { public: @@ -165,10 +167,11 @@ class SanityTestBloomFilter : public SanityTest { namespace { bool RunSanityTests(const std::string& command, const std::string& path) { std::vector sanity_tests = { - new SanityTestBasic(path), - new SanityTestSpecialComparator(path), + new SanityTestBasic(path), new SanityTestSpecialComparator(path), new SanityTestZlibCompression(path), +#ifndef ROCKSDB_LITE new SanityTestPlainTableFactory(path), +#endif // ROCKSDB_LITE new SanityTestBloomFilter(path)}; if (command == "create") { diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 8109c141e..a6d8c9ace 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -1789,16 +1789,24 @@ class StressTest { exit(1); } switch (FLAGS_rep_factory) { - case kHashSkipList: - options_.memtable_factory.reset(NewHashSkipListRepFactory(10000)); - break; case kSkipList: // no need to do anything break; +#ifndef ROCKSDB_LITE + case kHashSkipList: + options_.memtable_factory.reset(NewHashSkipListRepFactory(10000)); + break; case kVectorRep: options_.memtable_factory.reset(new VectorRepFactory()); break; +#else + default: + fprintf(stderr, + "RocksdbLite only supports skip list mem table. Skip " + "--rep_factory\n"); +#endif // ROCKSDB_LITE } + static Random purge_percent(1000); // no benefit from non-determinism here if (static_cast(purge_percent.Uniform(100)) < FLAGS_purge_redundant_percent - 1) { @@ -1884,9 +1892,14 @@ class StressTest { assert(!s.ok() || column_families_.size() == static_cast(FLAGS_column_families)); } else { +#ifndef ROCKSDB_LITE DBWithTTL* db_with_ttl; s = DBWithTTL::Open(options_, FLAGS_db, &db_with_ttl, FLAGS_ttl); db_ = db_with_ttl; +#else + fprintf(stderr, "TTL is not supported in RocksDBLite\n"); + exit(1); +#endif } if (!s.ok()) { fprintf(stderr, "open error: %s\n", s.ToString().c_str()); diff --git a/tools/ldb.cc b/tools/ldb.cc index 4581b8011..cb5ef5204 100644 --- a/tools/ldb.cc +++ b/tools/ldb.cc @@ -3,6 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. // +#ifndef ROCKSDB_LITE #include "rocksdb/ldb_tool.h" @@ -11,3 +12,10 @@ int main(int argc, char** argv) { tool.Run(argc, argv); return 0; } +#else +#include +int main(int argc, char** argv) { + fprintf(stderr, "Not supported in lite mode.\n"); + return 1; +} +#endif // ROCKSDB_LITE diff --git a/tools/sst_dump.cc b/tools/sst_dump.cc index 7a83b60b3..403893779 100644 --- a/tools/sst_dump.cc +++ b/tools/sst_dump.cc @@ -3,6 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. // +#ifndef ROCKSDB_LITE #include "rocksdb/sst_dump_tool.h" @@ -11,3 +12,10 @@ int main(int argc, char** argv) { tool.Run(argc, argv); return 0; } +#else +#include +int main(int argc, char** argv) { + fprintf(stderr, "Not supported in lite mode.\n"); + return 1; +} +#endif // ROCKSDB_LITE diff --git a/util/sst_dump_tool.cc b/util/sst_dump_tool.cc index be4e54da7..8d2233de8 100644 --- a/util/sst_dump_tool.cc +++ b/util/sst_dump_tool.cc @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. // +#ifndef ROCKSDB_LITE #include "rocksdb/sst_dump_tool.h" -#ifndef ROCKSDB_LITE - #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif