Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13941

collstats command not giving error as per documentation

    XMLWordPrintableJSON

Details

    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. 

      Attachments

        Activity

          People

            jason.price@mongodb.com Jason Price
            scott.mcgillivray@ubisoft.com Scott McGillivray
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 44 weeks, 5 days ago