Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4693

OperationFailure when running collstats

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.8
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      When running db.command('collstats', collection_name), I'm getting an OperationFailure exception for all collections.

      Please note:

      1. I'm connecting to a DocumentDB cluster.
      2. The same script works with no exception when connecting to a Mongo Atlas cluster.

      Script:

       

      def mongo_stats(config_file: str):
          config = read_config(config_file)
          cluster_name = config['cluster_name']
          mongo_client = MongoClient(**config['cluster_connection_options'])
          for db_name in mongo_client.list_database_names():
              db = mongo_client[db_name]
              for collection_name in mongo_client[db_name].list_collection_names():
                  _log.info('Getting stats for <%s> <%s>', db_name, collection_name)
                  try:
                      collection_stats = db.command('collstats', collection_name)
                  except OperationFailure as e:
                      _log.error('OperationFailure while getting stats:\n%s', e)
          _log.info('Done') 

      Log extract:

       

       

      2024-08-23 08:44:05 [INFO] You appear to be connected to a DocumentDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/documentdb 
      2024-08-23 08:44:05 [INFO] Getting stats for <cold_storage> <configuration>
      2024-08-23 08:44:05 [ERROR] OperationFailure while getting stats:
      Invalid namespace specified 'cold_storage.', full error: {'ok': 0.0, 'code': 73, 'errmsg': "Invalid namespace specified 'cold_storage.'", 'operationTime': Timestamp(1724402645, 1)}  2024-08-23 08:44:05 [INFO] Getting stats for <cold_storage> <service>
      2024-08-23 08:44:05 [ERROR] OperationFailure while getting stats:
      Invalid namespace specified 'cold_storage.', full error: {'ok': 0.0, 'code': 73, 'errmsg': "Invalid namespace specified 'cold_storage.'", 'operationTime': Timestamp(1724402645, 1)}
      ...

       

       

      Definition of done

      db.command('collstats', collection_name) shouldn't raise any exception and should return the collection statistics.

      Pitfalls

      The issue seems to be specific to DocumentDB.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            antoine.gardeux@ge.com Antoine GARDEUX
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: