diff options
author | Antonio Fuschetto <antonio.fuschetto@mongodb.com> | 2021-08-03 11:22:46 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-06 12:32:31 +0000 |
commit | 400820d43452952cc12ae8690e3157840e7a51d2 (patch) | |
tree | 058a8df03571573127062a816fb4c20f396c8b93 | |
parent | 3a58ebe0fd1d19f5afe38bd24ef2b7774c358828 (diff) | |
download | mongo-400820d43452952cc12ae8690e3157840e7a51d2.tar.gz |
SERVER-58570 Add a new field to config.collections/config.cache.collections representing whether a collection supports long names
-rw-r--r-- | src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/balancer/migration_test_fixture.h | 2 | ||||
-rw-r--r-- | src/mongo/db/s/collection_metadata_filtering_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/collection_sharding_runtime.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/shard_server_catalog_cache_loader_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/type_shard_collection.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/s/type_shard_collection.h | 4 | ||||
-rw-r--r-- | src/mongo/db/s/type_shard_collection.idl | 31 | ||||
-rw-r--r-- | src/mongo/s/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_collection.cpp | 12 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_collection.h | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_collection.idl | 24 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache.h | 2 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_loader.h | 2 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager.h | 2 | ||||
-rw-r--r-- | src/mongo/s/type_collection_common_types.idl (renamed from src/mongo/s/type_collection_timeseries_fields.idl) | 22 |
17 files changed, 112 insertions, 17 deletions
diff --git a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp index d987970efa8..9866790f137 100644 --- a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp +++ b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp @@ -34,7 +34,7 @@ #include "mongo/db/s/balancer/cluster_statistics_impl.h" #include "mongo/db/s/balancer/migration_test_fixture.h" #include "mongo/platform/random.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/balancer/migration_test_fixture.h b/src/mongo/db/s/balancer/migration_test_fixture.h index 12de7c22f1c..f74b55be93d 100644 --- a/src/mongo/db/s/balancer/migration_test_fixture.h +++ b/src/mongo/db/s/balancer/migration_test_fixture.h @@ -41,7 +41,7 @@ #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog/type_shard.h" #include "mongo/s/catalog/type_tags.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" namespace mongo { diff --git a/src/mongo/db/s/collection_metadata_filtering_test.cpp b/src/mongo/db/s/collection_metadata_filtering_test.cpp index 9d6d68a1fcf..0d10ba6de96 100644 --- a/src/mongo/db/s/collection_metadata_filtering_test.cpp +++ b/src/mongo/db/s/collection_metadata_filtering_test.cpp @@ -34,7 +34,7 @@ #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/s/shard_server_test_fixture.h" #include "mongo/s/catalog/type_chunk.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp index c08134ab030..90b47710027 100644 --- a/src/mongo/db/s/collection_sharding_runtime.cpp +++ b/src/mongo/db/s/collection_sharding_runtime.cpp @@ -39,7 +39,7 @@ #include "mongo/db/s/sharding_runtime_d_params_gen.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" #include "mongo/util/duration.h" namespace mongo { diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader_test.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader_test.cpp index 675fd1ee336..35b21e51896 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader_test.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader_test.cpp @@ -37,7 +37,7 @@ #include "mongo/s/catalog/type_collection.h" #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog_cache_loader_mock.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/type_shard_collection.cpp b/src/mongo/db/s/type_shard_collection.cpp index fa6e8d68ea0..707032eaeaf 100644 --- a/src/mongo/db/s/type_shard_collection.cpp +++ b/src/mongo/db/s/type_shard_collection.cpp @@ -86,4 +86,16 @@ void ShardCollectionType::setAllowMigrations(bool allowMigrations) { setPre50CompatibleAllowMigrations(false); } +SupportingLongNameStatusEnum ShardCollectionType::getSupportingLongName() const { + return ShardCollectionTypeBase::getSupportingLongName().get_value_or( + SupportingLongNameStatusEnum::kDisabled); +} + +void ShardCollectionType::setSupportingLongName(SupportingLongNameStatusEnum value) { + ShardCollectionTypeBase::setSupportingLongName( + value == SupportingLongNameStatusEnum::kDisabled + ? boost::none + : boost::optional<SupportingLongNameStatusEnum>(value)); +} + } // namespace mongo diff --git a/src/mongo/db/s/type_shard_collection.h b/src/mongo/db/s/type_shard_collection.h index a7b5f45792e..a10de2ea999 100644 --- a/src/mongo/db/s/type_shard_collection.h +++ b/src/mongo/db/s/type_shard_collection.h @@ -101,6 +101,10 @@ public: return getPre50CompatibleAllowMigrations().get_value_or(true); } void setAllowMigrations(bool allowMigrations); + + SupportingLongNameStatusEnum getSupportingLongName() const; + + void setSupportingLongName(SupportingLongNameStatusEnum value); }; } // namespace mongo diff --git a/src/mongo/db/s/type_shard_collection.idl b/src/mongo/db/s/type_shard_collection.idl index 3b86d7c1ca7..2bf73f19f7e 100644 --- a/src/mongo/db/s/type_shard_collection.idl +++ b/src/mongo/db/s/type_shard_collection.idl @@ -29,10 +29,10 @@ # ShardCollectionType type # # This type represents the layout and contents of documents contained in the shard server's -# config.collections collection. All manipulation of documents coming from that collection should -# be done with this class. +# config.cache.collections collection. All manipulation of documents coming from that collection +# should be done with this class. # -# Expected shard server config.collections collection format: +# Expected shard server config.cache.collections collection format: # { # "_id" : "foo.bar", # "uuid" : UUID, // optional in 3.6 @@ -66,7 +66,8 @@ # "fetchTimestamp" : Timestamp(3, 4), # "originalNamespace" : "foo.bar", # } -# } +# }, +# "supportingLongName" : "implicitly_enabled" // optional # } # @@ -78,7 +79,7 @@ imports: - "mongo/db/keypattern.idl" - "mongo/s/chunk_version.idl" - "mongo/s/resharding/type_collection_fields.idl" - - "mongo/s/type_collection_timeseries_fields.idl" + - "mongo/s/type_collection_common_types.idl" structs: ShardCollectionTypeBase: @@ -178,3 +179,23 @@ structs: description: "Time-series collection fields. Only set when this is a time-series buckets collection." optional: true + supportingLongName: + type: SupportingLongNameStatus + description: "When set, the maximum name length of sharded collections is aligned + with that of non-sharded collections, which is 255 bytes from MongoDB + version 4.4 and 120 bytes with earlier versions. Otherwise, the limit + for shared collections is reduced by 20 bytes, regardless of the + version of MongoDB. + + With version 5.1, the support for long names is implicitly enabled on + all collections by upgrading the feature compatibility version (FCV). + With FCV lower than 5.1 but using binaries supporting the feature, + the support for long names is disabled by default and requires an + explicit enabling on the specific collection. Otherwise, the feature + cannot be enabled in any way as unsupported by the binaries. + + From a technical perspective, enabling the feature, the + system.cache.chunks.<NS> collections are created or renamed using the + sharded collection UUID, instead of the namespace, as part of their + names, i.e., system.cache.chunks.<UUID>." + optional: true diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript index af45170771d..fd9dff8fff3 100644 --- a/src/mongo/s/SConscript +++ b/src/mongo/s/SConscript @@ -190,7 +190,7 @@ env.Library( 'shard_id.cpp', 'shard_invalidated_for_targeting_exception.cpp', 'stale_exception.cpp', - 'type_collection_timeseries_fields.idl', + 'type_collection_common_types.idl', 'would_change_owning_shard_exception.cpp', ], LIBDEPS=[ diff --git a/src/mongo/s/catalog/type_collection.cpp b/src/mongo/s/catalog/type_collection.cpp index 349bda5a43a..60bb0e0b836 100644 --- a/src/mongo/s/catalog/type_collection.cpp +++ b/src/mongo/s/catalog/type_collection.cpp @@ -99,4 +99,16 @@ void CollectionType::setMaxChunkSizeBytes(int64_t value) { CollectionTypeBase::setMaxChunkSizeBytes(value); } +SupportingLongNameStatusEnum CollectionType::getSupportingLongName() const { + return CollectionTypeBase::getSupportingLongName().get_value_or( + SupportingLongNameStatusEnum::kDisabled); +} + +void CollectionType::setSupportingLongName(SupportingLongNameStatusEnum value) { + CollectionTypeBase::setSupportingLongName( + value == SupportingLongNameStatusEnum::kDisabled + ? boost::none + : boost::optional<SupportingLongNameStatusEnum>(value)); +} + } // namespace mongo diff --git a/src/mongo/s/catalog/type_collection.h b/src/mongo/s/catalog/type_collection.h index ffdc31a4a64..b133295afda 100644 --- a/src/mongo/s/catalog/type_collection.h +++ b/src/mongo/s/catalog/type_collection.h @@ -171,6 +171,10 @@ public: else setPre50CompatibleAllowMigrations(false); } + + SupportingLongNameStatusEnum getSupportingLongName() const; + + void setSupportingLongName(SupportingLongNameStatusEnum value); }; } // namespace mongo diff --git a/src/mongo/s/catalog/type_collection.idl b/src/mongo/s/catalog/type_collection.idl index 3f91bbc0bee..76c8e088041 100644 --- a/src/mongo/s/catalog/type_collection.idl +++ b/src/mongo/s/catalog/type_collection.idl @@ -34,7 +34,7 @@ imports: - "mongo/db/keypattern.idl" - "mongo/s/chunk_version.idl" - "mongo/s/resharding/type_collection_fields.idl" - - "mongo/s/type_collection_timeseries_fields.idl" + - "mongo/s/type_collection_common_types.idl" structs: CollectionTypeBase: @@ -152,4 +152,24 @@ structs: type: TypeCollectionTimeseriesFields description: "Time-series collection fields. Only set when this is a time-series buckets collection." - optional: true
\ No newline at end of file + optional: true + supportingLongName: + type: SupportingLongNameStatus + description: "When set, the maximum name length of sharded collections is aligned + with that of non-sharded collections, which is 255 bytes from MongoDB + version 4.4 and 120 bytes with earlier versions. Otherwise, the limit + for shared collections is reduced by 20 bytes, regardless of the + version of MongoDB. + + With version 5.1, the support for long names is implicitly enabled on + all collections by upgrading the feature compatibility version (FCV). + With FCV lower than 5.1 but using binaries supporting the feature, + the support for long names is disabled by default and requires an + explicit enabling on the specific collection. Otherwise, the feature + cannot be enabled in any way as unsupported by the binaries. + + From a technical perspective, enabling the feature, the + system.cache.chunks.<NS> collections are created or renamed using the + sharded collection UUID, instead of the namespace, as part of their + names, i.e., system.cache.chunks.<UUID>." + optional: true diff --git a/src/mongo/s/catalog_cache.h b/src/mongo/s/catalog_cache.h index c5b73cdf529..21c448c46ee 100644 --- a/src/mongo/s/catalog_cache.h +++ b/src/mongo/s/catalog_cache.h @@ -35,7 +35,7 @@ #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog_cache_loader.h" #include "mongo/s/chunk_manager.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" #include "mongo/util/concurrency/thread_pool.h" #include "mongo/util/read_through_cache.h" diff --git a/src/mongo/s/catalog_cache_loader.h b/src/mongo/s/catalog_cache_loader.h index e16a8a3786a..3ac20415a47 100644 --- a/src/mongo/s/catalog_cache_loader.h +++ b/src/mongo/s/catalog_cache_loader.h @@ -38,7 +38,7 @@ #include "mongo/s/catalog/type_collection.h" #include "mongo/s/catalog/type_database.h" #include "mongo/s/chunk_version.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" #include "mongo/util/concurrency/notification.h" #include "mongo/util/uuid.h" diff --git a/src/mongo/s/catalog_cache_test.cpp b/src/mongo/s/catalog_cache_test.cpp index 0fba8df22d5..0d6827577ff 100644 --- a/src/mongo/s/catalog_cache_test.cpp +++ b/src/mongo/s/catalog_cache_test.cpp @@ -38,7 +38,7 @@ #include "mongo/s/catalog_cache_loader_mock.h" #include "mongo/s/sharding_router_test_fixture.h" #include "mongo/s/stale_exception.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" namespace mongo { namespace { diff --git a/src/mongo/s/chunk_manager.h b/src/mongo/s/chunk_manager.h index 970173ea07b..313f46bddc4 100644 --- a/src/mongo/s/chunk_manager.h +++ b/src/mongo/s/chunk_manager.h @@ -42,7 +42,7 @@ #include "mongo/s/database_version.h" #include "mongo/s/resharding/type_collection_fields_gen.h" #include "mongo/s/shard_key_pattern.h" -#include "mongo/s/type_collection_timeseries_fields_gen.h" +#include "mongo/s/type_collection_common_types_gen.h" #include "mongo/stdx/unordered_map.h" #include "mongo/util/concurrency/ticketholder.h" #include "mongo/util/read_through_cache.h" diff --git a/src/mongo/s/type_collection_timeseries_fields.idl b/src/mongo/s/type_collection_common_types.idl index 1fd68bb70de..a171faeb6fb 100644 --- a/src/mongo/s/type_collection_timeseries_fields.idl +++ b/src/mongo/s/type_collection_common_types.idl @@ -39,3 +39,25 @@ structs: inline_chained_structs: true chained_structs: TimeseriesOptions: TimeseriesOptions + +enums: + SupportingLongNameStatus: + description: "Enumeration representing different status of the support for long collection + names." + type: string + values: + # The support for long collection names is disabled. This happen when either the + # persisted collection metadata (i.e., config.collections and config.cache.collections) + # comes from binaries that do not support the feature or the feature is supported by the + # binaries but it has not been explicitly enabled. + kDisabled: "disabled" + + # The support for long collection names has been explicitly enabled. This happens when + # the binaries support the feature and the collection has been explicitly set to support + # a long name. + kExplicitlyEnabled: "explicitly_enabled" + + # The support for long collection names has been implicitly enabled. This happens when + # the binaries support the feature and by setting the feature compatibility version + # (FCV) to 5.1. + kImplicitlyEnabled: "implicitly_enabled" |