summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2020-08-06 12:49:37 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-02 19:40:18 +0000
commit89e6e8c17e28e00653c1f01870dc1481dbc72f12 (patch)
tree92c102754257b28fce74702f8ccf2b2d3a5bc5e5
parent03d22bb5884e280934d36702136d99a9363fb720 (diff)
downloadmongo-89e6e8c17e28e00653c1f01870dc1481dbc72f12.tar.gz
SERVER-50148 Fix use-after-move in MultiIndexBlock
(cherry picked from commit 992cff8ecbf93ff5fe8d2a1de44f0b80bacceea6)
-rw-r--r--src/mongo/db/catalog/multi_index_block.cpp4
-rw-r--r--src/mongo/db/catalog/multi_index_block.h2
-rw-r--r--src/mongo/db/index/index_access_method.cpp8
-rw-r--r--src/mongo/db/index/index_access_method.h10
4 files changed, 12 insertions, 12 deletions
diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp
index c7aede5a0fc..591d292ef45 100644
--- a/src/mongo/db/catalog/multi_index_block.cpp
+++ b/src/mongo/db/catalog/multi_index_block.cpp
@@ -601,7 +601,7 @@ Status MultiIndexBlock::dumpInsertsFromBulk(OperationContext* opCtx) {
}
Status MultiIndexBlock::dumpInsertsFromBulk(
- OperationContext* opCtx, IndexAccessMethod::RecordIdHandlerFn&& onDuplicateRecord) {
+ OperationContext* opCtx, const IndexAccessMethod::RecordIdHandlerFn& onDuplicateRecord) {
invariant(!_buildIsCleanedUp);
invariant(opCtx->lockState()->isNoop() || !opCtx->lockState()->inAWriteUnitOfWork());
for (size_t i = 0; i < _indexes.size(); i++) {
@@ -645,7 +645,7 @@ Status MultiIndexBlock::dumpInsertsFromBulk(
return Status::OK();
});
},
- std::move(onDuplicateRecord));
+ onDuplicateRecord);
if (!status.isOK()) {
return status;
diff --git a/src/mongo/db/catalog/multi_index_block.h b/src/mongo/db/catalog/multi_index_block.h
index b06bcd2bfcd..fb55f0ea5f0 100644
--- a/src/mongo/db/catalog/multi_index_block.h
+++ b/src/mongo/db/catalog/multi_index_block.h
@@ -169,7 +169,7 @@ public:
*/
Status dumpInsertsFromBulk(OperationContext* opCtx);
Status dumpInsertsFromBulk(OperationContext* opCtx,
- IndexAccessMethod::RecordIdHandlerFn&& onDuplicateRecord);
+ const IndexAccessMethod::RecordIdHandlerFn& onDuplicateRecord);
/**
* For background indexes using an IndexBuildInterceptor to capture inserts during a build,
* drain these writes into the index. If intent locks are held on the collection, more writes
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index b37c38e713c..030e3600bd3 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -606,8 +606,8 @@ int64_t AbstractIndexAccessMethod::BulkBuilderImpl::getKeysInserted() const {
Status AbstractIndexAccessMethod::commitBulk(OperationContext* opCtx,
BulkBuilder* bulk,
bool dupsAllowed,
- KeyHandlerFn&& onDuplicateKeyInserted,
- RecordIdHandlerFn&& onDuplicateRecord) {
+ const KeyHandlerFn& onDuplicateKeyInserted,
+ const RecordIdHandlerFn& onDuplicateRecord) {
Timer timer;
std::unique_ptr<BulkBuilder::Sorter::Iterator> it(bulk->done());
@@ -649,7 +649,7 @@ Status AbstractIndexAccessMethod::commitBulk(OperationContext* opCtx,
// Before attempting to insert, perform a duplicate key check.
bool isDup = (_descriptor->unique()) ? (cmpData == 0) : false;
if (isDup && !dupsAllowed) {
- Status status = _handleDuplicateKey(opCtx, data.first, std::move(onDuplicateRecord));
+ Status status = _handleDuplicateKey(opCtx, data.first, onDuplicateRecord);
if (!status.isOK()) {
return status;
}
@@ -801,7 +801,7 @@ std::string nextFileName() {
Status AbstractIndexAccessMethod::_handleDuplicateKey(OperationContext* opCtx,
const KeyString::Value& dataKey,
- RecordIdHandlerFn&& onDuplicateRecord) {
+ const RecordIdHandlerFn& onDuplicateRecord) {
RecordId recordId = KeyString::decodeRecordIdAtEnd(dataKey.getBuffer(), dataKey.getSize());
if (onDuplicateRecord) {
return onDuplicateRecord(recordId);
diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h
index 3a58f512159..6e40b9153b6 100644
--- a/src/mongo/db/index/index_access_method.h
+++ b/src/mongo/db/index/index_access_method.h
@@ -277,8 +277,8 @@ public:
virtual Status commitBulk(OperationContext* opCtx,
BulkBuilder* bulk,
bool dupsAllowed,
- KeyHandlerFn&& onDuplicateKeyInserted,
- RecordIdHandlerFn&& onDuplicateRecord) = 0;
+ const KeyHandlerFn& onDuplicateKeyInserted,
+ const RecordIdHandlerFn& onDuplicateRecord) = 0;
/**
* Specifies whether getKeys should relax the index constraints or not, in order of most
@@ -529,8 +529,8 @@ public:
Status commitBulk(OperationContext* opCtx,
BulkBuilder* bulk,
bool dupsAllowed,
- KeyHandlerFn&& onDuplicateKeyInserted,
- RecordIdHandlerFn&& onDuplicateRecord) final;
+ const KeyHandlerFn& onDuplicateKeyInserted,
+ const RecordIdHandlerFn& onDuplicateRecord) final;
void getKeys(const BSONObj& obj,
GetKeysMode mode,
@@ -599,7 +599,7 @@ private:
*/
Status _handleDuplicateKey(OperationContext* opCtx,
const KeyString::Value& dataKey,
- RecordIdHandlerFn&& onDuplicateRecord);
+ const RecordIdHandlerFn& onDuplicateRecord);
const std::unique_ptr<SortedDataInterface> _newInterface;
};