Following the migration of the mongodb driver from version 3.4.2 to version 3.11.2, we noticed an overconsumption of memory during our load tests.
This overconsumption was already existing in 3.4.2, but was accentuated in more recent versions following the addition of characters to check in the name of the database. (com.mongo.MongoNamespace.checkDatabaseNameValidity)
This overconsumption can be avoided, since the concatenated message is only necessary if the name of the database is not correct, whereas currently the message is concatenated with each call.
Several solutions to fix this :
- Find an error message to throw without concatenation. (Quickwin)
- Change the signature of the com.mongodb.assertions.Assertions.isTrueArgument method
- Add a cache for the check database name. If database name is present in the Set => no verification, if not present => verification and add to the set if it is correct, otherwise throw an error.
Example for second option :