summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Pe <erwin.pe@mongodb.com>2023-08-17 15:03:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-08-17 16:04:30 +0000
commit042115becd2bd287856864bc022373c5680a86f3 (patch)
tree90592b0513d6efae333c574c066975ebad895f95
parentfe142be3114a6947071266394cccace669d7004e (diff)
SERVER-78723 Disable __safeContent__ validation for encrypted collections when resharding
(cherry picked from commit 99b50fc1a02f9f7059f2d327a8a7737b14d52ba3)
-rw-r--r--jstests/sharding/libs/create_sharded_collection_util.js7
-rw-r--r--src/mongo/db/catalog/collection_write_path.cpp2
2 files changed, 7 insertions, 2 deletions
diff --git a/jstests/sharding/libs/create_sharded_collection_util.js b/jstests/sharding/libs/create_sharded_collection_util.js
index f6e34d01b81..8c5a929fc5a 100644
--- a/jstests/sharding/libs/create_sharded_collection_util.js
+++ b/jstests/sharding/libs/create_sharded_collection_util.js
@@ -2,7 +2,8 @@
var CreateShardedCollectionUtil = (function() {
/**
- * Shards a non-existing collection using the specified shard key and chunk ranges.
+ * Shards a non-existing collection (or an unsharded empty collection) using
+ * the specified shard key and chunk ranges.
*
* @param collection - a DBCollection object with an underlying Mongo connection to a mongos.
* @param chunks - an array of
@@ -19,7 +20,9 @@ var CreateShardedCollectionUtil = (function() {
assert.eq(null,
configDB.collections.findOne({ns: collection.getFullName()}),
"collection already exists as sharded");
- assert.eq(null, collection.exists(), "collection already exists as unsharded");
+ assert.eq([],
+ collection.aggregate([{$limit: 1}, {$replaceWith: {}}]).toArray(),
+ "collection already exists as non-empty unsharded collection");
// We include a UUID in the temporary zone names being generated to avoid conflicting with
// the names of any existing zones.
diff --git a/src/mongo/db/catalog/collection_write_path.cpp b/src/mongo/db/catalog/collection_write_path.cpp
index d6da790f23e..086cea05fee 100644
--- a/src/mongo/db/catalog/collection_write_path.cpp
+++ b/src/mongo/db/catalog/collection_write_path.cpp
@@ -409,6 +409,7 @@ Status insertDocuments(OperationContext* opCtx,
auto& validationSettings = DocumentValidationSettings::get(opCtx);
if (collection->getCollectionOptions().encryptedFieldConfig &&
+ !collection->ns().isTemporaryReshardingCollection() &&
!validationSettings.isSchemaValidationDisabled() &&
!validationSettings.isSafeContentValidationDisabled() &&
it->doc.hasField(kSafeContent)) {
@@ -521,6 +522,7 @@ void updateDocument(OperationContext* opCtx,
auto& validationSettings = DocumentValidationSettings::get(opCtx);
if (collection->getCollectionOptions().encryptedFieldConfig &&
+ !collection->ns().isTemporaryReshardingCollection() &&
!validationSettings.isSchemaValidationDisabled() &&
!validationSettings.isSafeContentValidationDisabled()) {