diff options
author | Alison Lu <alison.lu@mongodb.com> | 2021-08-16 21:39:48 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-20 14:06:53 +0000 |
commit | 083ee77d8a1644b78c1d94dbef86e73eecaeccff (patch) | |
tree | d1e61a76719e904df2e8a7bee4c9e126e95f365c /src/mongo | |
parent | f8a9735544d43a9a3a6bb607bdc6c893369cf61e (diff) | |
download | mongo-083ee77d8a1644b78c1d94dbef86e73eecaeccff.tar.gz |
SERVER-58797 Enable hint for time-series metaField-only updates
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index e66f94cad73..bda5a38b7a8 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -104,6 +104,7 @@ MONGO_FAIL_POINT_DEFINE(hangBeforeChildRemoveOpIsPopped); MONGO_FAIL_POINT_DEFINE(hangAfterAllChildRemoveOpsArePopped); MONGO_FAIL_POINT_DEFINE(hangDuringBatchInsert); MONGO_FAIL_POINT_DEFINE(hangDuringBatchUpdate); +MONGO_FAIL_POINT_DEFINE(hangAfterBatchUpdate); MONGO_FAIL_POINT_DEFINE(hangDuringBatchRemove); MONGO_FAIL_POINT_DEFINE(hangAndFailAfterDocumentInsertsReserveOpTimes); // The withLock fail points are for testing interruptability of these operations, so they will not @@ -805,6 +806,15 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx, << *metaField << ": " << ns, timeseries::updateOnlyModifiesMetaField(opCtx, ns, updateMod, *metaField)); + // Only translate the hint (if there is one) if it is specified with an index specification + // document. + if (!updateRequest->getHint().isEmpty() && + updateRequest->getHint().firstElement().fieldNameStringData() != "$hint"_sd) { + updateRequest->setHint( + uassertStatusOK(timeseries::createBucketsIndexSpecFromTimeseriesIndexSpec( + *timeseriesOptions, updateRequest->getHint()))); + } + updateRequest->setQuery(timeseries::translateQuery(updateQuery, *metaField)); updateRequest->setUpdateModification(timeseries::translateUpdate(updateMod, *metaField)); } @@ -867,6 +877,9 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx, result.setNModified(updateResult.numDocsModified); result.setUpsertedId(updateResult.upsertedId); + CurOpFailpointHelpers::waitWhileFailPointEnabled( + &hangAfterBatchUpdate, opCtx, "hangAfterBatchUpdate"); + if (containsDotsAndDollarsField && updateResult.containsDotsAndDollarsField) { *containsDotsAndDollarsField = true; } @@ -1107,8 +1120,9 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx, timeseriesOptions); // Only translate the hint if it is specified by index spec. - if (request.getHint().firstElement().fieldNameStringData() != "$hint"_sd || - request.getHint().firstElement().type() != BSONType::String) { + if (!request.getHint().isEmpty() && + (request.getHint().firstElement().fieldNameStringData() != "$hint"_sd || + request.getHint().firstElement().type() != BSONType::String)) { request.setHint( uassertStatusOK(timeseries::createBucketsIndexSpecFromTimeseriesIndexSpec( *timeseriesOptions, request.getHint()))); |