[DOCS-13941] collstats command not giving error as per documentation Created: 07/Sep/20  Updated: 12/Dec/23  Resolved: 28/Jan/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.4.0, 4.2.6, 5.0.0, 5.2.0, 5.3.0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Bug Priority: Major - P3
Reporter: Scott McGillivray Assignee: Jason Price
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-51206 collStats command does not return an ... Closed
Problem/Incident
is caused by SERVER-29678 collStats should return ok:1 and all ... Closed
Participants:
Days since reply: 2 years, 1 week, 6 days ago
Epic Link: DOCSP-11701
Story Points: 3

 Description   

Using these versions

pymongo '3.11.0'

mongo '4.2.6'

 when i run this i get back a couple of collections as expected

collections = client.core.list_collection_names()

when i run this for a collection name that doesn't exist in the database i get the below output. 

tats = client.core.command("collstats", 'idontexist')

 

{{ 'sharded': False, 'primary': 'rs2', 'indexDetails': {}, 'ns': 'core.idontexist', 'count': 0, 'size': 0, 'storageSize': 0, 'totalIndexSize': 0, 'indexSizes': {}, 'avgObjSize': 0.0, 'maxSize': 0, 'nindexes': 0, 'nchunks': 1, 'shards': { 'rs2': { 'ns': 'core.idontexist', 'size': 0, 'count': 0, 'storageSize': 0, 'nindexes': 0, 'totalIndexSize': 0, 'indexDetails': {}, 'indexSizes': {}, 'scaleFactor': 1, 'ok': 1.0, '$gleStats': { 'lastOpTime': Timestamp(0, 0), 'electionId': ObjectId('7fffffff0000000000000001') }, 'lastCommittedOpTime': Timestamp(1599457270, 1), '$configServerState': { 'opTime': { 'ts': Timestamp(1599457268, 2), 't': 2 } }, '$clusterTime': { 'clusterTime': Timestamp(1599457270, 1), 'signature': { 'hash': b '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0 } }, 'operationTime': Timestamp(1599457270, 1) } }, 'ok': 1.0, 'operationTime': Timestamp(1599457270, 1), '$clusterTime': { 'clusterTime': Timestamp(1599457270, 1), 'signature': { 'hash': b 'm\xa5e_]#\x97\xb6\x8a\xdd\x16}\xc8 \xaas\x90\x8e\xaf\xeb', 'keyId': 6833584828143632415 } }}

which is odd because the documentation says:
"If the collection does not exist, collStats returns an error message."

Just curious if this is expected behaviour ? Shouldn't pymongo have returned an error ?

Thanks. 



 Comments   
Comment by Githook User [ 28/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13941-collstats-error (#433) (#442)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v4.4
https://github.com/10gen/docs-mongodb-internal/commit/96e4667b8f33d2eeb67808509a7237d9d830b174

Comment by Githook User [ 28/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13941-collstats-error (#433) (#441)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v5.0
https://github.com/10gen/docs-mongodb-internal/commit/34b41007355476fa5f332484066529f550c62471

Comment by Githook User [ 28/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13941-collstats-error (#433) (#440)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v5.2
https://github.com/10gen/docs-mongodb-internal/commit/66b36074b42ee4a0badb26d54b5667431b4f2824

Comment by Githook User [ 27/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13941-collstats-error (#433)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: master
https://github.com/10gen/docs-mongodb-internal/commit/47c899655306a28de82af8669839449d467ba198

Comment by Shane Harvey [ 21/Oct/20 ]

Moving this to the DOCS project because this appears to be a bug in the server documentation for collStats. In particular, it says:

If the collection does not exist, collStats returns an error message.

But this is not always the case on recent server versions, see SERVER-29678 and SERVER-51206.

Comment by Shane Harvey [ 29/Sep/20 ]

Upon further investigation, it looks like the server documentation for collStats is incorrect. SERVER-29678 changed collStats to not return an error when the collection does not exist in MongoDB 4.2 and up (at least on replica sets). The inconsistent behavior within sharded clusters should be addressed by SERVER-51206.

We should update the documentation to be in line with the recent server behavior.

Comment by Shane Harvey [ 29/Sep/20 ]

SERVER-50070 is specifically only about MongoDB 3.6 whereas this ticket uses MongoDB 4.2. Nonetheless, Bernie is right that this is a server issue affecting 4.2 and 4.4, not a pymongo bug. I filed SERVER-51206 for the server team to address it.

Comment by Bernie Hackett [ 07/Sep/20 ]

This looks like the server bug reported in SERVER-50070. In most cases PyMongo relies on the server to return an error when necessary. We generally don't want to add custom error handling that would have to be removed or altered as the server changes over time.

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