Not the answer you need?
Register and ask your own question!

listCollections performance issue in 4.2

ddoussotddoussot Current User Role Beginner
Hi there,
We have an application in production with API servers, developped in .Net Core. The APIs call a MongoDB Percona cluster hosted on premise.
We have 10 server, and each servers contains 40 API instances.
We used to perform a healthcheck every 5 s on each API instance. This healthcheck simply connects to MongoDB and calls listCollections.
Everything was working fine till MongoDB Percona 4.0, but when we migrated to 4.2 performances decreased a lot. We found out that the healthcheck was responsible of this situation. It is like if listCollections puts some locks or something it did not do before. One we deactivated healthCheck, everything was fine.
However this makes me worry about other performances issue.
Has anyone encounter such issue when migrating to 4.2 ?
Thanks.
Tagged:

Answers

  • mike_graysonmike_grayson Percona Staff Role
    edited August 12
    Hi There,
    This is related to a change in behavior with the listCollections command starting in MongoDB 4.0, if the behavior you're looking for is to just list the name of the collections, you would need to add the nameOnly flag to get that behavior.  Specifically citing this part of the documentation, "Returning just the name and type (view or collection) does not take collection-level locks whereas returning full collection information locks each collection in the database."   https://docs.mongodb.com/manual/reference/command/listCollections/#dbcmd.listCollections
     You can see how the listCollections command as-is would now have collection level locks which would impact performance.   Additionally, adding the authorizedCollections parameter can avoid unnecessary errors in your log if the user that you run the listCollections command does not have access to all collections.   For example,
    db.adminCommand({"listCollections": 1, "nameOnly": 1, "authorizedCollections": true}
    would return the collection names for only the collections that you are authorized to list.

    Thanks,
    Mike
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.