diff options
author | Geert Bosch <geert.bosch@mongodb.com> | 2019-10-11 16:38:35 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-11 16:38:35 +0000 |
commit | 1e702a5ca25a2e78756380d1ef22d8e12b94694c (patch) | |
tree | 60c20bedd3fe12554ff5a899bc4b8735e08662d5 /src/mongo/db/storage | |
parent | e178d59bf39212f4eca5d00a3e8b4a7378094c53 (diff) | |
download | mongo-1e702a5ca25a2e78756380d1ef22d8e12b94694c.tar.gz |
SERVER-43747 Skip getKeySize for non-unique indexes
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 549475c368e..8cfbac8622e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -1162,9 +1162,10 @@ protected: // Most keys will have a RecordId appended to the end, with the exception of the _id index // and timestamp unsafe unique indexes. The contract of this function is to always return a // KeyString with a RecordId, so append one if it does not exists already. - auto sizeWithoutRecordId = - KeyString::getKeySize(_key.getBuffer(), _key.getSize(), _idx.getOrdering(), _typeBits); - if (_key.getSize() == sizeWithoutRecordId) { + if (_idx.unique() && + _key.getSize() == + KeyString::getKeySize( + _key.getBuffer(), _key.getSize(), _idx.getOrdering(), _typeBits)) { // Create a copy of _key with a RecordId. Because _key is used during cursor restore(), // appending the RecordId would cause the cursor to be repositioned incorrectly. KeyString::Builder keyWithRecordId(_key); |