summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2022-03-19 00:52:30 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-19 01:22:51 +0000
commit93cd5e2ab3c457741f708d821abc64a5d1f23d21 (patch)
treed9e3f692f6de19899ddf60a8b750c559269f6dd1 /src/mongo/s
parentc141ef8536d51f05a6fa4017de20286d154d09e1 (diff)
downloadmongo-93cd5e2ab3c457741f708d821abc64a5d1f23d21.tar.gz
SERVER-63494 Enable WouldChangeOwningShard update and findAndModify tests with chunk migrations
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/would_change_owning_shard_exception.cpp3
-rw-r--r--src/mongo/s/would_change_owning_shard_exception.h15
2 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/s/would_change_owning_shard_exception.cpp b/src/mongo/s/would_change_owning_shard_exception.cpp
index 10b2f77b45b..ac131fb9440 100644
--- a/src/mongo/s/would_change_owning_shard_exception.cpp
+++ b/src/mongo/s/would_change_owning_shard_exception.cpp
@@ -58,7 +58,8 @@ std::shared_ptr<const ErrorExtraInfo> WouldChangeOwningShardInfo::parse(const BS
WouldChangeOwningShardInfo WouldChangeOwningShardInfo::parseFromCommandError(const BSONObj& obj) {
return WouldChangeOwningShardInfo(obj[kPreImage].Obj().getOwned(),
obj[kPostImage].Obj().getOwned(),
- obj[kShouldUpsert].Bool());
+ obj[kShouldUpsert].Bool(),
+ boost::none);
}
} // namespace mongo
diff --git a/src/mongo/s/would_change_owning_shard_exception.h b/src/mongo/s/would_change_owning_shard_exception.h
index 639d1806ffb..3468e062586 100644
--- a/src/mongo/s/would_change_owning_shard_exception.h
+++ b/src/mongo/s/would_change_owning_shard_exception.h
@@ -32,6 +32,7 @@
#include "mongo/base/error_extra_info.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/db/namespace_string.h"
namespace mongo {
@@ -48,10 +49,12 @@ public:
explicit WouldChangeOwningShardInfo(const BSONObj& preImage,
const BSONObj& postImage,
- const bool shouldUpsert)
+ const bool shouldUpsert,
+ boost::optional<NamespaceString> ns)
: _preImage(preImage.getOwned()),
_postImage(postImage.getOwned()),
- _shouldUpsert(shouldUpsert) {}
+ _shouldUpsert(shouldUpsert),
+ _ns(ns) {}
const auto& getPreImage() const {
return _preImage;
@@ -65,6 +68,10 @@ public:
return _shouldUpsert;
}
+ const auto& getNs() const {
+ return _ns;
+ }
+
BSONObj toBSON() const {
BSONObjBuilder bob;
serialize(&bob);
@@ -84,6 +91,10 @@ private:
// True if {upsert: true} and the update stage did not match any docs
bool _shouldUpsert;
+
+ // The namespace of the collection containing the document. Does not get serialized into the
+ // BSONObj for this error.
+ boost::optional<NamespaceString> _ns;
};
using WouldChangeOwningShardException = ExceptionFor<ErrorCodes::WouldChangeOwningShard>;