diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2019-06-26 06:42:49 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2019-06-26 06:42:49 +1000 |
commit | 8b1d5ef199d881ab4fce61e585006436e9e6d2d1 (patch) | |
tree | 17ee6e19aee7dd7efb5ee557210905951d9e5c8e /src/mongo | |
parent | 58f209ca5ebe15ffbaec95b26f5b6a7b957f6510 (diff) | |
download | mongo-8b1d5ef199d881ab4fce61e585006436e9e6d2d1.tar.gz |
SERVER-41913 Avoid in-place modify operations for logged collections.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h | 2 |
2 files changed, 12 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 0f192eac7f3..97fd85aaaf5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -645,6 +645,10 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine, _engineName(params.engineName), _isCapped(params.isCapped), _isEphemeral(params.isEphemeral), + _isLogged(!isTemp() && WiredTigerUtil::useTableLogging( + NamespaceString(ns()), + getGlobalReplSettings().usingReplSets() || + repl::ReplSettings::shouldRecoverFromOplogAsStandalone())), _isOplog(NamespaceString::oplog(params.ns)), _cappedMaxSize(params.cappedMaxSize), _cappedMaxSizeSlack(std::min(params.cappedMaxSize / 10, int64_t(16 * 1024 * 1024))), @@ -679,11 +683,8 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine, invariant(_cappedMaxDocs == -1); } - if (!params.isReadOnly && !isTemp()) { - bool replicatedWrites = getGlobalReplSettings().usingReplSets() || - repl::ReplSettings::shouldRecoverFromOplogAsStandalone(); - uassertStatusOK(WiredTigerUtil::setTableLogging( - ctx, _uri, WiredTigerUtil::useTableLogging(NamespaceString(ns()), replicatedWrites))); + if (!params.isReadOnly) { + uassertStatusOK(WiredTigerUtil::setTableLogging(ctx, _uri, _isLogged)); } if (_isOplog) { @@ -1407,12 +1408,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 b448e76ea52..546974eb4a3 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -342,6 +342,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; |