diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-06-02 12:50:30 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-06-02 12:50:30 +1000 |
commit | afd931c9e4b1662f6032a1a6e452829694056635 (patch) | |
tree | 9663359e7e10d7107cf7a87eb0e4af38f37ebec8 /api | |
parent | 056c3a2fa8108cc124e19eff74ba950b8f39c4ca (diff) | |
download | mongo-afd931c9e4b1662f6032a1a6e452829694056635.tar.gz |
Bump the default number of sessions for LevelDB, until we figure out how to safely close the sessions when threads exit (db_bench creates multiple sets of threads on the same connection).
Also make DestoryDB quieter: check for the existence of the special "WiredTiger" file before attempting to open.
Diffstat (limited to 'api')
-rw-r--r-- | api/leveldb/leveldb_wt.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/api/leveldb/leveldb_wt.cc b/api/leveldb/leveldb_wt.cc index fe6b8f0ee26..f994eb30a77 100644 --- a/api/leveldb/leveldb_wt.cc +++ b/api/leveldb/leveldb_wt.cc @@ -6,6 +6,7 @@ */ #include "leveldb_wt.h" #include <sys/stat.h> +#include <unistd.h> #include <sstream> using leveldb::Cache; @@ -28,7 +29,8 @@ using leveldb::Value; #endif #define WT_URI "table:data" -#define WT_CONFIG "type=lsm,leaf_page_max=4KB,leaf_item_max=1KB," +#define WT_CONN_CONFIG "session_max=256," +#define WT_TABLE_CONFIG "type=lsm,leaf_page_max=4KB,leaf_item_max=1KB," /* Destructors required for interfaces. */ leveldb::DB::~DB() {} @@ -128,10 +130,11 @@ Cache *NewLRUCache(size_t capacity) { Status DestroyDB(const std::string& name, const Options& options) { fprintf(stderr, "DestroyDB %s", name.c_str()); WT_CONNECTION *conn; - int ret = ::wiredtiger_open(name.c_str(), NULL, NULL, &conn); - /* If the database cannot be opened, there is nothing to destroy. */ - if (ret != 0) + /* If the database doesn't exist, there is nothing to destroy. */ + if (access((name + "/WiredTiger").c_str(), F_OK) != 0) return Status::OK(); + int ret = ::wiredtiger_open(name.c_str(), NULL, NULL, &conn); + assert(ret == 0); WT_SESSION *session; ret = conn->open_session(conn, NULL, NULL, &session); assert(ret == 0); @@ -331,6 +334,7 @@ leveldb::DB::Open(const Options &options, const std::string &name, leveldb::DB * { // Build the wiredtiger_open config. std::stringstream s_conn; + s_conn << WT_CONN_CONFIG; if (options.create_if_missing) { (void)mkdir(name.c_str(), 0777); s_conn << "create,"; @@ -349,7 +353,7 @@ leveldb::DB::Open(const Options &options, const std::string &name, leveldb::DB * if (options.create_if_missing) { std::stringstream s_table; - s_table << WT_CONFIG; + s_table << WT_TABLE_CONFIG; s_table << "internal_page_max=" << options.block_size << ","; s_table << "leaf_page_max=" << options.block_size << ","; if (options.compression == kSnappyCompression) |