-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.7.1
-
Component/s: Sharding
-
Fully Compatible
-
Sharding 2018-02-12, Sharding 2018-02-26, Sharding 2018-03-12
The “allowImplicitCollectionCreation” field on the OperationShardingState (decoration on OperationContext), which defaulted to “true” in 3.6, will now default to “false”. Only the explicit “create” command on mongod will set “allowImplicitCollectionCreation” to “true”. This means any paths on shards that would have implicitly created a collection will now throw CannotImplicitlyCreateCollection.
Shards will catch “CannotImplicitlyCreateCollection” at the same place they currently catch “StaleShardVersion.” At this point, they will send _configsvrCreateCollection to the config server (see _configsvrCreateCollection logic below). The config server will create the collection on the primary shard (most likely, the same shard that sent the _configsvrCreateCollection, though it’s possible movePrimary ran between when the shard checked mongos’s databaseVersion and when the config server took the distlock for _configsvrCreateCollection).
The shard will return the “CannotImplicitlyCreateCollection” error to mongos. This error code will be added to ErrorCodes::isStaleShardingError(), so that mongos also refreshes and retries the request.