diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-02 16:06:46 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-02 16:06:46 +1100 |
commit | 2f6817253ebfef52f06c55f5a58a799997e014ad (patch) | |
tree | 53ec987ed98fdc7906e72a56bc001c3994060ab5 | |
parent | 1b522cf5745c40754f9d5aa4f4e35def4e8fee74 (diff) | |
download | mongo-2f6817253ebfef52f06c55f5a58a799997e014ad.tar.gz |
SERVER-16667 Only truncate if we find some documents.
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 4d696fa7791..cbdb2512412 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -418,12 +418,14 @@ namespace { if (ret != WT_NOTFOUND) invariantWTOK(ret); - WriteUnitOfWork wuow( txn ); - ret = c->session->truncate(c->session, NULL, NULL, c, NULL); - invariantWTOK(ret); - _changeNumRecords(txn, -docsRemoved); - _increaseDataSize(txn, -sizeSaved); - wuow.commit(); + if (docsRemoved > 0) { + WriteUnitOfWork wuow( txn ); + ret = c->session->truncate(c->session, NULL, NULL, c, NULL); + invariantWTOK(ret); + _changeNumRecords(txn, -docsRemoved); + _increaseDataSize(txn, -sizeSaved); + wuow.commit(); + } } catch ( const WriteConflictException& wce ) { delete txn->releaseRecoveryUnit(); |