Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdbcUtils#openConnection sets unrelated polyglot.engine.WarnInterpreterOnly property #3882

Open
myazinn opened this issue Apr 26, 2024 · 2 comments

Comments

@myazinn
Copy link

myazinn commented Apr 26, 2024

Which version and edition of Flyway are you using?

10.11.1

If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)

It is the latest one

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using? (Type & version)

Postgresql 15.5

Which operating system are you using?

Doesn't matter

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

In our project, we use flyway and a bunch of graalvm libs

groupId = "org.graalvm.sdk",     artifactId = "graal-sdk"
groupId = "org.graalvm.js",      artifactId = "js"
groupId = "org.graalvm.truffle", artifactId = "truffle-api"

of version 21.1.0.
With newer versions of flyway our service stopped working because org.graalvm.polyglot.Context.Builder can no longer create a org.graalvm.polyglot.Context and fails with the following error

Could not find option with name engine.WarnInterpreterOnly.

This flag was introduced in 21.2.0, while we use 21.1.0. There are reason why we use this particular old version, so unfortunately we cannot just bump it. We were surprised to find out that this flag is being set by flyway for Postgres, which doesn't have any graalvm-related dependencies.
It seems the issue was introduced here. The commit message states that it was intended to set property to hide warning from polyglot engine, but why? Why would one library set a system property that belongs to other, completely unrelated, library?
I see there was an issue regarding this flag related to MongoDB. Perhaps it makes sense for Mongo specifically (even though sounds weird to me), but why do this in JdbcUtils?

What did you expect to see?

That everything works fine

What did you see instead?

For some bizarre reason org.flywaydb.core.internal.jdbc.JdbcUtils#openConnection sets polyglot.engine.WarnInterpreterOnly system property to "false".
Making matters worse, it's not deterministic and depends on the initialisation order. If org.graalvm.polyglot.Context happens to be created before we open any DB connection, that everything works fine. Otherwise, we get an error.
In our case, we had to remove this property manually (System.clearProperty("polyglot.engine.WarnInterpreterOnly")) to make it work. But that's neither a good workaround, nor a real solution.

@Barry-RG
Copy link
Contributor

Thank you for your issue. The reason is due to the MongoDB driver use by Flyway requiring that option to be set global. As Flyway does not usualy interact with GraalVM it was not seen as an issue initially. However, I appreciate the way you are using Flyway has hit this issue and I will raise a ticket in our development pipeline to deal with this appropriately.

@selliera
Copy link

Oh, I just got caught by this, because I do have code that tries to reset properties between tests. It does this using System.clearProperty, and at least with java17, results in:

java.lang.ClassCastException: java.lang.Boolean incompatible with java.lang.String
	at java.base/java.lang.System.clearProperty(System.java:956)

As this method assumes the property values are strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants