[COMPASS-6526] Investigate changes in SERVER-60064: Create on an existing collection on mongod should have the same behavior as mongos Created: 16/Feb/23  Updated: 29/Oct/23  Resolved: 24/Feb/23

Status: Closed
Project: Compass
Component/s: None
Affects Version/s: None
Fix Version/s: No version

Type: Investigation Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-60064 Make create command idempotent on mongod Closed
Documentation Changes: Not Needed

 Description   
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.



 Comments   
Comment by Anna Henningsen [ 24/Feb/23 ]

No devtools impact expected here

Generated at Wed Feb 07 22:43:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.