summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2014-08-26 14:27:17 -0400
committerSusan LoVerso <sue@wiredtiger.com>2014-08-26 14:27:17 -0400
commita99330cea9cb3bddddd1469252060009b80b7e52 (patch)
tree1a874951f0042178f8ef78fbf43631f702f0f9eb /api
parentdcedda0903f7b408cc8df5d0f4bc219abccb7aa8 (diff)
downloadmongo-a99330cea9cb3bddddd1469252060009b80b7e52.tar.gz
Fix __log_filesize to look for end in larger chunks.
Fix ReplayIterator::Valid() to retry if it's invalid. #1106
Diffstat (limited to 'api')
-rw-r--r--api/leveldb/hyper_wt.cc15
-rw-r--r--api/leveldb/leveldb_test.cc6
2 files changed, 19 insertions, 2 deletions
diff --git a/api/leveldb/hyper_wt.cc b/api/leveldb/hyper_wt.cc
index 44435ce5520..b147ff6fe75 100644
--- a/api/leveldb/hyper_wt.cc
+++ b/api/leveldb/hyper_wt.cc
@@ -64,7 +64,7 @@ class ReplayIteratorImpl : public ReplayIterator {
// An iterator is either positioned at a deleted key, present key/value pair,
// or not valid. This method returns true iff the iterator is valid.
- virtual bool Valid() { return valid_; }
+ virtual bool Valid();
// Moves to the next entry in the source. After this call, Valid() is
// true iff the iterator was not positioned at the last entry in the source.
@@ -157,6 +157,14 @@ class ReplayIteratorImpl : public ReplayIterator {
uint32_t fileid, opcount, optype, rectype;
};
+bool
+ReplayIteratorImpl::Valid() {
+ // If we're invalid and at the end, try again.
+ if (valid_ == false && cursor_ != NULL && status_.IsNotFound())
+ Next();
+ return valid_;
+}
+
void
ReplayIteratorImpl::Next() {
int ret = 0;
@@ -181,7 +189,10 @@ ReplayIteratorImpl::Next() {
status_ = WiredTigerErrorToStatus(ret);
if (ret != 0) {
valid_ = false;
- ret = Close();
+ if (ret != WT_NOTFOUND)
+ ret = Close();
+ else
+ ret = 0;
assert(ret == 0);
}
}
diff --git a/api/leveldb/leveldb_test.cc b/api/leveldb/leveldb_test.cc
index 12c5906f5fa..25cfe0c379e 100644
--- a/api/leveldb/leveldb_test.cc
+++ b/api/leveldb/leveldb_test.cc
@@ -93,6 +93,12 @@ extern "C" int main() {
cout << replay_start->key().ToString() << ": " << replay_start->value().ToString() << endl;
replay_start->Next();
}
+ // We reached the end of log, iterator should still not be valid.
+ // But if we write something, the iterator should find it and become
+ // valid again.
+ assert(!replay_start->Valid());
+ s = db->Put(leveldb::WriteOptions(), "key6", "value6");
+ assert(replay_start->Valid());
db->ReleaseReplayIterator(replay_start);
db->ReleaseReplayIterator(replay_ts);
db->ReleaseReplayIterator(replay_now);