summaryrefslogtreecommitdiff
path: root/src/mongo/s/catalog
diff options
context:
space:
mode:
authorAntonio Fuschetto <antonio.fuschetto@mongodb.com>2021-10-18 20:54:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-18 22:30:30 +0000
commit01cb4a206af83bf49da4fa750aba4a3f4aeaea10 (patch)
tree4aa7d910e1493b79a43a697be7e7f2e8a4aff980 /src/mongo/s/catalog
parente99ec2cde2134987506b708cf624cdc5ef4bdb77 (diff)
downloadmongo-01cb4a206af83bf49da4fa750aba4a3f4aeaea10.tar.gz
SERVER-60489 Handle potential exceptions in balancer recovery phase
Diffstat (limited to 'src/mongo/s/catalog')
-rw-r--r--src/mongo/s/catalog/type_chunk.cpp8
-rw-r--r--src/mongo/s/catalog/type_chunk.h13
2 files changed, 16 insertions, 5 deletions
diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp
index bae8a9fc02b..b3dade41a54 100644
--- a/src/mongo/s/catalog/type_chunk.cpp
+++ b/src/mongo/s/catalog/type_chunk.cpp
@@ -217,7 +217,8 @@ ChunkType::ChunkType(CollectionUUID collectionUUID,
_version(std::move(version)),
_shard(std::move(shardId)) {}
-StatusWith<ChunkType> ChunkType::parseFromConfigBSONCommand(const BSONObj& source) {
+StatusWith<ChunkType> ChunkType::parseFromConfigBSONCommand(const BSONObj& source,
+ bool requireUUID) {
ChunkType chunk;
{
@@ -249,9 +250,8 @@ StatusWith<ChunkType> ChunkType::parseFromConfigBSONCommand(const BSONObj& sourc
}
}
- // There must be at least uuid
- if (!chunk._collectionUUID) {
- return {ErrorCodes::FailedToParse, str::stream() << "There must be a uuid present"};
+ if (requireUUID && !chunk._collectionUUID) {
+ return {ErrorCodes::FailedToParse, str::stream() << "There must be a UUID present"};
}
{
diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h
index 02c702e1db4..ec18c389dd7 100644
--- a/src/mongo/s/catalog/type_chunk.h
+++ b/src/mongo/s/catalog/type_chunk.h
@@ -225,7 +225,10 @@ public:
* Also does validation of the contents. Note that 'parseFromConfigBSONCommand' does not return
* ErrorCodes::NoSuchKey if the '_id' field is missing while 'fromConfigBSON' does.
*/
- static StatusWith<ChunkType> parseFromConfigBSONCommand(const BSONObj& source);
+ // TODO (SERVER-60792): Get rid of "requireUUID" once v6.0 branches out. Starting from v5.1, the
+ // collection UUID will always be present in the chunk.
+ static StatusWith<ChunkType> parseFromConfigBSONCommand(const BSONObj& source,
+ bool requireUUID = true);
static StatusWith<ChunkType> fromConfigBSON(const BSONObj& source,
const OID& epoch,
const Timestamp& timestamp);
@@ -259,6 +262,14 @@ public:
* Getters and setters.
*/
+ // TODO (SERVER-60792): Get rid of this function once v6.0 branches out. Due to a missing
+ // addition of the UUID field in v5.0 BalanceChunkRequest, it can happen that the field is not
+ // set. Mark as "UNSAFE" to make it clear that this method is just intended to be used for this
+ // specific purpose.
+ bool hasCollectionUUID_UNSAFE() const {
+ return (bool)_collectionUUID;
+ }
+
const CollectionUUID& getCollectionUUID() const {
invariant(_collectionUUID);
return *_collectionUUID;