[DOCS-15906] [SERVER] Create on an existing collection on mongod should have the same behavior as mongos Created: 16/Feb/23  Updated: 13/Nov/23  Resolved: 28/Jul/23

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 7.0.0-rc0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Jason Price
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-60064 Make create command idempotent on mongod Closed
Participants:
Days since reply: 27 weeks, 6 days ago

 Description   

Original title: Investigate changes in SERVER-60064: Create on an existing collection on mongod should have the same behavior as mongos

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 Jason Price [ 27/Jul/23 ]

https://github.com/10gen/docs-mongodb-internal/pull/4179

Generated at Thu Feb 08 08:14:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.