-
Type: Investigation
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
Original Downstream Change Summary
The create command will now report success on mongod if a collection/view with an identical namespace and options already exists. Note that this was already the behavior on mongos as of MongoDB 4.0.
Description of Linked Ticket
Related to SERVER-33276 and PYTHON-1936. Starting in MongoDB 4.0, the create command does not return an error when the collection already exists on sharded clusters:
>>> client.server_info()['version'] '4.2.3' >>> client.is_mongos True >>> client.test.command('create', 'test', check=False) {'ok': 1.0} >>> client.test.command('create', 'test', check=False) {'ok': 1.0}
On replica sets and standalones the second create fails with error code 48:
>>> client.server_info()['version'] '4.2.3' >>> client.is_mongos False >>> client.test.command('create', 'test', check=False) {'ok': 1.0} >>> client.test.command('create', 'test', check=False) {'ok': 0.0, 'errmsg': "a collection 'test.test' already exists", 'code': 48, 'codeName': 'NamespaceExists'}
We should make mongod have the same behavior as mongos for consistency across deployments.
Another benefit of this change is that it would allow drivers to retry the create command like mongos does.
- depends on
-
SERVER-60064 Make create command idempotent on mongod
- Closed