-
Type:
Task
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 4.8
-
Component/s: None
-
None
-
None
-
Python Drivers
-
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:
- I'm connecting to a DocumentDB cluster.
- 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.