You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Java API
What database are you using (type & version)?
MongoDB 3.3
What operating system are you using?
OSX El Capitan
What did you do?
(Please include the content causing the issue, any relevant configuration settings, and the command you ran)
Run the info() and the migrate() commands on MongoFlyway.
What did you expect to see?
info and migrate
What did you see instead?
So the internal mongoclient closes its connection after any single command. So running info and migrate are two commands and that won't work. An external mongoclient will work. However when setting a mongoclient into MongoFlyway, you do not capture a databaseName. Therefore, when constructing the MongoMetaDataTable, an NPE is thrown and migration fails. Our workaround is to add an overloaded setMongoClient that adds a databaseName as a second argument.
The text was updated successfully, but these errors were encountered:
This is an expected behavior. If the MongoClient is not explicitly created by the user and provided to mongoFlyway using setMongoClient method, then mongoFlyway will create its own MongoClient which it will terminate after running a flyway command. If you want to run more than one flyway command, then you must provide your own MongoClient instance and flyway won't close it. However, in such a case, the user must take precaution to close the MongoClient instance to release mongo connections.
I see now. If I set the 'flyway.mongoUri' config property, the configuration routine will internally call another overloaded setMongoClient method which will then instantiate the 'databaseName' instance variable which will be needed later on. It didn't make sense to me to set this property because I am supplying the MongoClient. There are problems with the way the code works. First, when I add my external MongoClient, it will replace the internal mongoClient, and that first-created internal MongoClient's connection will not close. Second, the 'createMongoClient' boolean used to keep track of whether to close the MongoClient after a command is executed will be true or false based on the order in which the user calls flyway.configure() and flyway.setMongoClient. This is fragile and will lead to frustrated users.
My workaround was to create in mongo-flyway an overloaded setMongoClient command that accepts a databaseName arg. Looks like a few lines of additional code might be wise here.
What version of Flyway are you using?
release-4.0.3-mongodb
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Java API
What database are you using (type & version)?
MongoDB 3.3
What operating system are you using?
OSX El Capitan
What did you do?
(Please include the content causing the issue, any relevant configuration settings, and the command you ran)
Run the info() and the migrate() commands on MongoFlyway.
What did you expect to see?
info and migrate
What did you see instead?
So the internal mongoclient closes its connection after any single command. So running info and migrate are two commands and that won't work. An external mongoclient will work. However when setting a mongoclient into MongoFlyway, you do not capture a databaseName. Therefore, when constructing the MongoMetaDataTable, an NPE is thrown and migration fails. Our workaround is to add an overloaded setMongoClient that adds a databaseName as a second argument.
The text was updated successfully, but these errors were encountered: