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
main
sdong 10 years ago
parent f822129b32
commit a177742a9b
  1. 24
      db/db_bench.cc
  2. 5
      db/perf_context_test.cc
  3. 10
      table/table_reader_bench.cc
  4. 8
      tools/blob_store_bench.cc
  5. 9
      tools/db_repl_stress.cc
  6. 7
      tools/db_sanity_test.cc
  7. 19
      tools/db_stress.cc
  8. 8
      tools/ldb.cc
  9. 8
      tools/sst_dump.cc
  10. 3
      util/sst_dump_tool.cc

@ -1878,14 +1878,15 @@ class Benchmark {
exit(1); exit(1);
} }
switch (FLAGS_rep_factory) { switch (FLAGS_rep_factory) {
case kPrefixHash:
options.memtable_factory.reset(NewHashSkipListRepFactory(
FLAGS_hash_bucket_count));
break;
case kSkipList: case kSkipList:
options.memtable_factory.reset(new SkipListFactory( options.memtable_factory.reset(new SkipListFactory(
FLAGS_skip_list_lookahead)); FLAGS_skip_list_lookahead));
break; break;
#ifndef ROCKSDB_LITE
case kPrefixHash:
options.memtable_factory.reset(
NewHashSkipListRepFactory(FLAGS_hash_bucket_count));
break;
case kHashLinkedList: case kHashLinkedList:
options.memtable_factory.reset(NewHashLinkListRepFactory( options.memtable_factory.reset(NewHashLinkListRepFactory(
FLAGS_hash_bucket_count)); FLAGS_hash_bucket_count));
@ -1899,8 +1900,14 @@ class Benchmark {
options.memtable_factory.reset(NewHashCuckooRepFactory( options.memtable_factory.reset(NewHashCuckooRepFactory(
options.write_buffer_size, FLAGS_key_size + FLAGS_value_size)); options.write_buffer_size, FLAGS_key_size + FLAGS_value_size));
break; break;
#else
default:
fprintf(stderr, "Only skip list is supported in lite mode\n");
exit(1);
#endif // ROCKSDB_LITE
} }
if (FLAGS_use_plain_table) { if (FLAGS_use_plain_table) {
#ifndef ROCKSDB_LITE
if (FLAGS_rep_factory != kPrefixHash && if (FLAGS_rep_factory != kPrefixHash &&
FLAGS_rep_factory != kHashLinkedList) { FLAGS_rep_factory != kHashLinkedList) {
fprintf(stderr, "Waring: plain table is used with skipList\n"); fprintf(stderr, "Waring: plain table is used with skipList\n");
@ -1921,7 +1928,12 @@ class Benchmark {
plain_table_options.hash_table_ratio = 0.75; plain_table_options.hash_table_ratio = 0.75;
options.table_factory = std::shared_ptr<TableFactory>( options.table_factory = std::shared_ptr<TableFactory>(
NewPlainTableFactory(plain_table_options)); 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) { } else if (FLAGS_use_cuckoo_table) {
#ifndef ROCKSDB_LITE
if (FLAGS_cuckoo_hash_ratio > 1 || FLAGS_cuckoo_hash_ratio < 0) { if (FLAGS_cuckoo_hash_ratio > 1 || FLAGS_cuckoo_hash_ratio < 0) {
fprintf(stderr, "Invalid cuckoo_hash_ratio\n"); fprintf(stderr, "Invalid cuckoo_hash_ratio\n");
exit(1); exit(1);
@ -1931,6 +1943,10 @@ class Benchmark {
table_options.identity_as_first_hash = FLAGS_identity_as_first_hash; table_options.identity_as_first_hash = FLAGS_identity_as_first_hash;
options.table_factory = std::shared_ptr<TableFactory>( options.table_factory = std::shared_ptr<TableFactory>(
NewCuckooTableFactory(table_options)); NewCuckooTableFactory(table_options));
#else
fprintf(stderr, "Cuckoo table is not supported in lite mode\n");
exit(1);
#endif // ROCKSDB_LITE
} else { } else {
BlockBasedTableOptions block_based_options; BlockBasedTableOptions block_based_options;
if (FLAGS_use_hash_search) { if (FLAGS_use_hash_search) {

@ -38,8 +38,13 @@ std::shared_ptr<DB> OpenDb(bool read_only = false) {
FLAGS_min_write_buffer_number_to_merge; FLAGS_min_write_buffer_number_to_merge;
if (FLAGS_use_set_based_memetable) { if (FLAGS_use_set_based_memetable) {
#ifndef ROCKSDB_LITE
options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(0)); options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(0));
options.memtable_factory.reset(NewHashSkipListRepFactory()); options.memtable_factory.reset(NewHashSkipListRepFactory());
#else
fprintf(stderr, "Prefix hash is not supported in lite mode\n");
exit(1);
#endif // ROCKSDB_LITE
} }
Status s; Status s;

@ -257,12 +257,18 @@ int main(int argc, char** argv) {
options.compression = rocksdb::CompressionType::kNoCompression; options.compression = rocksdb::CompressionType::kNoCompression;
if (FLAGS_table_factory == "cuckoo_hash") { if (FLAGS_table_factory == "cuckoo_hash") {
#ifndef ROCKSDB_LITE
options.allow_mmap_reads = true; options.allow_mmap_reads = true;
env_options.use_mmap_reads = true; env_options.use_mmap_reads = true;
rocksdb::CuckooTableOptions table_options; rocksdb::CuckooTableOptions table_options;
table_options.hash_table_ratio = 0.75; table_options.hash_table_ratio = 0.75;
tf.reset(rocksdb::NewCuckooTableFactory(table_options)); 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") { } else if (FLAGS_table_factory == "plain_table") {
#ifndef ROCKSDB_LITE
options.allow_mmap_reads = true; options.allow_mmap_reads = true;
env_options.use_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)); tf.reset(new rocksdb::PlainTableFactory(plain_table_options));
options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform( options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(
FLAGS_prefix_len)); 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") { } else if (FLAGS_table_factory == "block_based") {
tf.reset(new rocksdb::BlockBasedTableFactory()); tf.reset(new rocksdb::BlockBasedTableFactory());
} else { } else {

@ -3,6 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
#ifndef ROCKSDB_LITE
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include <atomic> #include <atomic>
@ -282,3 +283,10 @@ int main(int argc, const char** argv) {
return 0; return 0;
} }
#else // ROCKSDB_LITE
#include <stdio.h>
int main(int argc, char** argv) {
fprintf(stderr, "Not supported in lite mode.\n");
return 1;
}
#endif // ROCKSDB_LITE

@ -3,6 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
#ifndef ROCKSDB_LITE
#ifndef GFLAGS #ifndef GFLAGS
#include <cstdio> #include <cstdio>
int main() { int main() {
@ -145,3 +146,11 @@ int main(int argc, const char** argv) {
} }
#endif // GFLAGS #endif // GFLAGS
#else // ROCKSDB_LITE
#include <stdio.h>
int main(int argc, char** argv) {
fprintf(stderr, "Not supported in lite mode.\n");
return 1;
}
#endif // ROCKSDB_LITE

@ -131,6 +131,7 @@ class SanityTestZlibCompression : public SanityTest {
Options options_; Options options_;
}; };
#ifndef ROCKSDB_LITE
class SanityTestPlainTableFactory : public SanityTest { class SanityTestPlainTableFactory : public SanityTest {
public: public:
explicit SanityTestPlainTableFactory(const std::string& path) explicit SanityTestPlainTableFactory(const std::string& path)
@ -146,6 +147,7 @@ class SanityTestPlainTableFactory : public SanityTest {
private: private:
Options options_; Options options_;
}; };
#endif // ROCKSDB_LITE
class SanityTestBloomFilter : public SanityTest { class SanityTestBloomFilter : public SanityTest {
public: public:
@ -165,10 +167,11 @@ class SanityTestBloomFilter : public SanityTest {
namespace { namespace {
bool RunSanityTests(const std::string& command, const std::string& path) { bool RunSanityTests(const std::string& command, const std::string& path) {
std::vector<SanityTest*> sanity_tests = { std::vector<SanityTest*> sanity_tests = {
new SanityTestBasic(path), new SanityTestBasic(path), new SanityTestSpecialComparator(path),
new SanityTestSpecialComparator(path),
new SanityTestZlibCompression(path), new SanityTestZlibCompression(path),
#ifndef ROCKSDB_LITE
new SanityTestPlainTableFactory(path), new SanityTestPlainTableFactory(path),
#endif // ROCKSDB_LITE
new SanityTestBloomFilter(path)}; new SanityTestBloomFilter(path)};
if (command == "create") { if (command == "create") {

@ -1789,16 +1789,24 @@ class StressTest {
exit(1); exit(1);
} }
switch (FLAGS_rep_factory) { switch (FLAGS_rep_factory) {
case kHashSkipList:
options_.memtable_factory.reset(NewHashSkipListRepFactory(10000));
break;
case kSkipList: case kSkipList:
// no need to do anything // no need to do anything
break; break;
#ifndef ROCKSDB_LITE
case kHashSkipList:
options_.memtable_factory.reset(NewHashSkipListRepFactory(10000));
break;
case kVectorRep: case kVectorRep:
options_.memtable_factory.reset(new VectorRepFactory()); options_.memtable_factory.reset(new VectorRepFactory());
break; 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 static Random purge_percent(1000); // no benefit from non-determinism here
if (static_cast<int32_t>(purge_percent.Uniform(100)) < if (static_cast<int32_t>(purge_percent.Uniform(100)) <
FLAGS_purge_redundant_percent - 1) { FLAGS_purge_redundant_percent - 1) {
@ -1884,9 +1892,14 @@ class StressTest {
assert(!s.ok() || column_families_.size() == assert(!s.ok() || column_families_.size() ==
static_cast<size_t>(FLAGS_column_families)); static_cast<size_t>(FLAGS_column_families));
} else { } else {
#ifndef ROCKSDB_LITE
DBWithTTL* db_with_ttl; DBWithTTL* db_with_ttl;
s = DBWithTTL::Open(options_, FLAGS_db, &db_with_ttl, FLAGS_ttl); s = DBWithTTL::Open(options_, FLAGS_db, &db_with_ttl, FLAGS_ttl);
db_ = db_with_ttl; db_ = db_with_ttl;
#else
fprintf(stderr, "TTL is not supported in RocksDBLite\n");
exit(1);
#endif
} }
if (!s.ok()) { if (!s.ok()) {
fprintf(stderr, "open error: %s\n", s.ToString().c_str()); fprintf(stderr, "open error: %s\n", s.ToString().c_str());

@ -3,6 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
// //
#ifndef ROCKSDB_LITE
#include "rocksdb/ldb_tool.h" #include "rocksdb/ldb_tool.h"
@ -11,3 +12,10 @@ int main(int argc, char** argv) {
tool.Run(argc, argv); tool.Run(argc, argv);
return 0; return 0;
} }
#else
#include <stdio.h>
int main(int argc, char** argv) {
fprintf(stderr, "Not supported in lite mode.\n");
return 1;
}
#endif // ROCKSDB_LITE

@ -3,6 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
// //
#ifndef ROCKSDB_LITE
#include "rocksdb/sst_dump_tool.h" #include "rocksdb/sst_dump_tool.h"
@ -11,3 +12,10 @@ int main(int argc, char** argv) {
tool.Run(argc, argv); tool.Run(argc, argv);
return 0; return 0;
} }
#else
#include <stdio.h>
int main(int argc, char** argv) {
fprintf(stderr, "Not supported in lite mode.\n");
return 1;
}
#endif // ROCKSDB_LITE

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
// //
#ifndef ROCKSDB_LITE
#include "rocksdb/sst_dump_tool.h" #include "rocksdb/sst_dump_tool.h"
#ifndef ROCKSDB_LITE
#ifndef __STDC_FORMAT_MACROS #ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#endif #endif

Loading…
Cancel
Save