From 33025572fa0964a67528f9f2317a0f2cd6a03310 Mon Sep 17 00:00:00 2001 From: Geert Bosch Date: Thu, 30 Nov 2017 14:05:06 -0500 Subject: SERVER-32125 Only add/remove UUIDs during upgrade/downgrade (cherry picked from commit e1f3a9bccaadce1772d6cf7d5f9b44ca3adbee3e) --- .../causally_consistent_jscore_passthrough.yml | 1 + .../causally_consistent_jscore_passthrough_auth.yml | 1 + ...arded_causally_consistent_jscore_passthrough.yml | 1 + .../sharded_collections_jscore_passthrough.yml | 1 + .../suites/sharding_jscore_op_query_passthrough.yml | 1 + .../suites/sharding_jscore_passthrough.yml | 1 + jstests/core/collmod_without_uuid.js | 21 +++++++++++++++++++++ src/mongo/db/catalog/coll_mod.cpp | 5 ++++- 8 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 jstests/core/collmod_without_uuid.js diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml index 91ec0dc9f48..9375455afb3 100644 --- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml @@ -14,6 +14,7 @@ selector: - jstests/core/capped_update.js # uses godinsert and can't run under replication. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/dbadmin.js # "local" database. diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml index 735cadb9bc8..6eae135b43e 100644 --- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml +++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml @@ -29,6 +29,7 @@ selector: - jstests/core/capped_update.js # uses godinsert and can't run under replication. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/dbadmin.js # "local" database. diff --git a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml index fbd53ee4dc2..5cfda647f17 100644 --- a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml @@ -17,6 +17,7 @@ selector: - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/auth_copydb.js # copyDatabase. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/copydatabase_no_id_index.js # copyDatabase. - jstests/core/copydb.js # copyDatabase. - jstests/core/dbadmin.js # "local" database. diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml index c9b23f10d29..cfe1a9577f6 100644 --- a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml @@ -12,6 +12,7 @@ selector: - jstests/core/capped*.js # capped collections. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/auth_copydb.js # copyDatabase. diff --git a/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml b/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml index 13d7efd7319..1f575054328 100644 --- a/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml @@ -14,6 +14,7 @@ selector: - jstests/core/capped_update.js # uses godinsert and can't run under replication. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/dbadmin.js # "local" database. diff --git a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml index 2059124e280..96a90ae1c00 100644 --- a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml @@ -14,6 +14,7 @@ selector: - jstests/core/capped_update.js # uses godinsert and can't run under replication. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. + - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - jstests/core/dbadmin.js # "local" database. diff --git a/jstests/core/collmod_without_uuid.js b/jstests/core/collmod_without_uuid.js new file mode 100644 index 00000000000..87d65d398b2 --- /dev/null +++ b/jstests/core/collmod_without_uuid.js @@ -0,0 +1,21 @@ +/** + * SERVER-32125 Check that applyOps commands with collMod without UUID don't strip it + */ +(function() { + "use strict"; + const collName = "collmod_without_uuid"; + + function checkUUIDs() { + let infos = db.getCollectionInfos(); + assert(infos.every((coll) => coll.name != collName || coll.info.uuid != undefined), + "Not all collections have UUIDs: " + tojson({infos})); + } + + db[collName].drop(); + assert.writeOK(db[collName].insert({})); + checkUUIDs(); + let cmd = {applyOps: [{ns: "test.$cmd", op: "c", o: {collMod: collName}}]}; + let res = db.runCommand(cmd); + assert.commandWorked(res, tojson(cmd)); + checkUUIDs(); +})(); diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 4d5a4bac55c..b6c6c61d374 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -48,6 +48,7 @@ #include "mongo/db/index/index_descriptor.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/s/sharding_state.h" +#include "mongo/db/server_options.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/recovery_unit.h" #include "mongo/db/views/view_catalog.h" @@ -433,7 +434,9 @@ Status _collModInternal(OperationContext* opCtx, log() << "Assigning UUID " << uuid.get().toString() << " to collection " << coll->ns(); CollectionCatalogEntry* cce = coll->getCatalogEntry(); cce->addUUID(opCtx, uuid.get(), coll); - } else if (!uuid && coll->uuid()) { + } else if (!uuid && coll->uuid() && + serverGlobalParams.featureCompatibility.getVersion() != + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo36) { log() << "Removing UUID " << coll->uuid().get().toString() << " from collection " << coll->ns(); CollectionCatalogEntry* cce = coll->getCatalogEntry(); -- cgit v1.2.1