diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2022-04-13 15:49:02 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-13 20:49:59 +0000 |
commit | 4606b3cd56fd4ca9c5c39ebc8a0f7e0cfb790f9e (patch) | |
tree | b9e24e7a5c530b115fe0adc1f0eb536c6a4d1ac8 /src | |
parent | 66cb1dcbee5ecc7c388bec5fa0136b4205f67a58 (diff) | |
download | mongo-4606b3cd56fd4ca9c5c39ebc8a0f7e0cfb790f9e.tar.gz |
SERVER-65454: Reset curop namespace after config.image_collection lookup.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/op_observer_impl.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_retryability.cpp | 8 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index b08a246c84d..9f0bc23aa28 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -2268,6 +2268,7 @@ env.Library( 'update/update_driver', ], LIBDEPS_PRIVATE=[ + 'curop', 'repl/image_collection_entry', ], ) diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index 8e3c1c93b7d..1180a93fd86 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -76,6 +76,7 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" #include "mongo/scripting/engine.h" +#include "mongo/stdx/mutex.h" #include "mongo/util/assert_util.h" #include "mongo/util/fail_point.h" @@ -313,8 +314,15 @@ void writeToImageCollection(OperationContext* opCtx, AllowLockAcquisitionOnTimestampedUnitOfWork allowLockAcquisition(opCtx->lockState()); AutoGetCollection imageCollectionRaii( opCtx, NamespaceString::kConfigImagesNamespace, LockMode::MODE_IX); + auto curOp = CurOp::get(opCtx); + const std::string existingNs = curOp->getNS(); UpdateResult res = Helpers::upsert( opCtx, NamespaceString::kConfigImagesNamespace.toString(), imageEntry.toBSON()); + { + stdx::lock_guard<Client> clientLock(*opCtx->getClient()); + curOp->setNS_inlock(existingNs); + } + invariant(res.numDocsModified == 1 || !res.upsertedId.isEmpty()); } diff --git a/src/mongo/db/ops/write_ops_retryability.cpp b/src/mongo/db/ops/write_ops_retryability.cpp index 41dcdd121f3..1f1c28cda28 100644 --- a/src/mongo/db/ops/write_ops_retryability.cpp +++ b/src/mongo/db/ops/write_ops_retryability.cpp @@ -34,12 +34,14 @@ #include "mongo/db/ops/write_ops_retryability.h" #include "mongo/bson/util/bson_extract.h" +#include "mongo/db/curop.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/namespace_string.h" #include "mongo/db/ops/write_ops_gen.h" #include "mongo/db/repl/image_collection_entry_gen.h" #include "mongo/logv2/log.h" #include "mongo/logv2/redaction.h" +#include "mongo/stdx/mutex.h" namespace mongo { namespace { @@ -118,8 +120,14 @@ BSONObj extractPreOrPostImage(OperationContext* opCtx, const repl::OplogEntry& o LogicalSessionId sessionId = oplog.getSessionId().get(); TxnNumber txnNumber = oplog.getTxnNumber().get(); Timestamp ts = oplog.getTimestamp(); + auto curOp = CurOp::get(opCtx); + const std::string existingNS = curOp->getNS(); BSONObj imageDoc = client.findOne(NamespaceString::kConfigImagesNamespace, BSON("_id" << sessionId.toBSON())); + { + stdx::lock_guard<Client> clientLock(*opCtx->getClient()); + curOp->setNS_inlock(existingNS); + } if (imageDoc.isEmpty()) { LOGV2_WARNING(5676402, "Image lookup for a retryable findAndModify was not found", |