diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2019-06-26 06:42:49 +1000 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2019-07-31 09:25:56 -0400 |
commit | 201d8b967486df9b9cc0948507b537b520371467 (patch) | |
tree | ef865e8c979c2e5c773004aecc28f018a3df6443 /src/mongo | |
parent | e01b2ea5d1ecb076159a2e260524c2a2e381d36d (diff) | |
download | mongo-201d8b967486df9b9cc0948507b537b520371467.tar.gz |
SERVER-41913 Avoid in-place modify operations for logged collections.
(cherry picked from commit 8b1d5ef199d881ab4fce61e585006436e9e6d2d1)
(cherry picked from commit abf661c2657e08a53c4fd13d939b4587ddaf734d)
(cherry picked from commit b583a5704eaf895facadaf470ddd9cf2bfe6270e)
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 92957b49c45..58a655038c2 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -65,8 +65,8 @@ namespace mongo { -using std::unique_ptr; using std::string; +using std::unique_ptr; namespace { @@ -610,6 +610,8 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine, _engineName(params.engineName), _isCapped(params.isCapped), _isEphemeral(params.isEphemeral), + _isLogged(WiredTigerUtil::useTableLogging(NamespaceString(ns()), + getGlobalReplSettings().usingReplSets())), _isOplog(NamespaceString::oplog(params.ns)), _cappedMaxSize(params.cappedMaxSize), _cappedMaxSizeSlack(std::min(params.cappedMaxSize / 10, int64_t(16 * 1024 * 1024))), @@ -642,11 +644,7 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine, } if (!params.isReadOnly) { - uassertStatusOK(WiredTigerUtil::setTableLogging( - ctx, - _uri, - WiredTigerUtil::useTableLogging(NamespaceString(ns()), - getGlobalReplSettings().usingReplSets()))); + uassertStatusOK(WiredTigerUtil::setTableLogging(ctx, _uri, _isLogged)); } if (_isOplog) { @@ -1273,12 +1271,15 @@ Status WiredTigerRecordStore::updateRecord(OperationContext* opCtx, // Check if we should modify rather than doing a full update. Look for deltas for documents // larger than 1KB, up to 16 changes representing up to 10% of the data. + // + // Skip modify for logged tables: don't trust WiredTiger's recovery with operations that are not + // idempotent. const int kMinLengthForDiff = 1024; const int kMaxEntries = 16; const int kMaxDiffBytes = len / 10; bool skip_update = false; - if (len > kMinLengthForDiff && len <= old_length + kMaxDiffBytes) { + if (!_isLogged && len > kMinLengthForDiff && len <= old_length + kMaxDiffBytes) { int nentries = kMaxEntries; std::vector<WT_MODIFY> entries(nentries); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index a5c5feee3be..e2e46eaf9bf 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -309,6 +309,8 @@ private: const bool _isCapped; // True if the storage engine is an in-memory storage engine const bool _isEphemeral; + // True if WiredTiger is logging updates to this table + const bool _isLogged; // True if the namespace of this record store starts with "local.oplog.", and false otherwise. const bool _isOplog; int64_t _cappedMaxSize; |