Don't do memtable lookup in db_impl_readonly if memtables are empty while opening db.

Summary: In DBImpl::Recover method, while loading memtables, also check if memtables are empty. Use this in DBImplReadonly to determine whether to lookup memtable or not.

Test Plan:
db_test
make check all

Reviewers: sdong, yhchiang, ljin, igor

Reviewed By: ljin

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D22281
This commit is contained in:
Radheshyam Balasundaram 2014-08-26 17:19:03 -07:00
parent 9dcb75b6d9
commit b6fd7811eb
4 changed files with 15 additions and 2 deletions

View File

@ -117,7 +117,6 @@ TESTS = \
thread_local_test \
geodb_test \
rate_limiter_test \
cuckoo_table_builder_test \
options_test \
cuckoo_table_builder_test \
cuckoo_table_reader_test \

View File

@ -16,7 +16,6 @@
#include <stdint.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include "db/db_iter.h"
#include "db/dbformat.h"
#include "db/filename.h"

View File

@ -1195,6 +1195,16 @@ TEST(DBTest, ReadOnlyDB) {
}
ASSERT_EQ(count, 2);
delete iter;
Close();
// Reopen and flush memtable.
Reopen();
Flush();
Close();
// Now check keys in read only mode.
ASSERT_OK(ReadOnlyReopen(&options));
ASSERT_EQ("v3", Get("foo"));
ASSERT_EQ("v2", Get("bar"));
}
// Make sure that when options.block_cache is set, after a new table is

View File

@ -417,6 +417,11 @@ static bool SaveValue(void* arg, const char* entry) {
bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
MergeContext& merge_context, const Options& options) {
// The sequence number is updated synchronously in version_set.h
if (first_seqno_ == 0) {
// Avoiding recording stats for speed.
return false;
}
PERF_TIMER_AUTO(get_from_memtable_time);
Slice user_key = key.user_key();