summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-07-01 10:06:59 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2015-07-01 10:06:59 +1000
commit0e10c86f515c28c626567a642ba20b93adca0459 (patch)
treefd3e055e6ee504567761e97af5f04fa472979e6a /src/mongo/db/storage
parent965e3b062530c2834f584d115063fd54b4329d52 (diff)
downloadmongo-0e10c86f515c28c626567a642ba20b93adca0459.tar.gz
SERVER-19178 Fix a bug positioning cursors for capped collection truncates
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 28b814f7e77..35fac985c98 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -462,11 +462,15 @@ namespace {
WiredTigerCursor curwrap( _uri, _instanceId, true, txn);
WT_CURSOR *c = curwrap.get();
RecordId newestOld;
+ int64_t firstKey = 0;
int first = 0, ret = 0;
if (_cappedFirstRecord != RecordId()) {
c->set_key(c, _makeKey(_cappedFirstRecord));
- invariantWTOK(WT_OP_CHECK(c->search_near(c, NULL)));
- first = 1;
+ if ((ret = WT_OP_CHECK(c->search(c))) != WT_NOTFOUND) {
+ invariantWTOK(ret);
+ invariantWTOK(c->get_key(c, &firstKey));
+ first = 1;
+ }
}
while ((sizeSaved < sizeOverCap || docsRemoved < docsOverCap) &&
@@ -514,9 +518,9 @@ namespace {
WiredTigerCursor startWrap( _uri, _instanceId, true, txn);
WT_CURSOR* start = NULL;
- if (_cappedFirstRecord != RecordId()) {
+ if (firstKey != 0) {
start = startWrap.get();
- start->set_key(start, _makeKey(_cappedFirstRecord));
+ start->set_key(start, firstKey);
}
ret = session->truncate(session, NULL, start, c, NULL);