question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unsupported Database: MariaDB 10.4

See original GitHub issue
Which version and edition of Flyway are you using?

7.8.2 (latest)

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

Java API

Which database are you using? (Type & version)

MariaDB 10.4

Which operating system are you using?

Debian 10

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)
var flyway = Flyway.configure(classLoader).dataSource(dataSource).load();
try {
    flyway.migrate();
} catch (final FlywayException e) {
    return Result.error(e);
}
What did you expect to see?

Successful migration

What did you see instead?
[21:01:49 INFO]: [org.flywaydb.core.internal.license.VersionPrinter] Flyway Community Edition 7.8.2 by Redgate
[21:01:49 INFO]: [com.zaxxer.hikari.HikariDataSource] SamplePool - Starting...
[21:01:49 INFO]: [com.zaxxer.hikari.HikariDataSource] SamplePool - Start completed.
[21:01:49 ERROR]: [ExamplePlugin] Jdbc url: jdbc:mariadb://127.0.0.1:3306/app?useUnicode=true&characterEncoding=utf-8&useSSL=false
[21:01:49 ERROR]: [ExamplePlugin] Migration error: 
org.flywaydb.core.api.FlywayException: Unsupported Database: MariaDB 10.4
                at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:143) ~[?:?]
                at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:69) ~[?:?]
                at org.flywaydb.core.Flyway.execute(Flyway.java:505) ~[?:?]
                at org.flywaydb.core.Flyway.migrate(Flyway.java:165) ~[?:?]
                at ru.example.clans.service.simple.SqlMigrateService.migrate(SqlMigrateService.java:30) ~[?:?]
                at ru.example.clans.ExamplePlugin.onPluginEnable(ExamplePlugin.java:95) ~[?:?]
                at ru.coder.api.BenioPlugin.onEnable(BenioPlugin.java:51) ~[?:?]
                at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-638]
                at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-638]
                at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-638]
                at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-638]
                at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-638]
                at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) ~[patched_1.16.5.jar:git-Paper-638]
                at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:281) ~[patched_1.16.5.jar:git-Paper-638]
                at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-638]
                at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-638]
                at java.lang.Thread.run(Thread.java:832) [?:?]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
A248commented, May 14, 2021

Test case with JUnit 5:

public class Flyway3168Test {

	private DataSource dataSource;

	@BeforeEach
	public void initDataSource() {
		HikariConfig hikariConfig = new HikariConfig();
		hikariConfig.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
		hikariConfig.setJdbcUrl("jdbc:hsqldb:mem:testdb");
		dataSource = new HikariDataSource(hikariConfig);
	}

	private void migrate() {
		Flyway.configure(getClass().getClassLoader())
				.locations("classpath:test-migrations") // Uses some migrations in src/test/resources/test-migrations
				.dataSource(dataSource)
				.load().migrate();
	}

	private void migrateUsing(ClassLoader contextClassLoader) {
		Thread currentThread = Thread.currentThread();
		ClassLoader originalLoader = currentThread.getContextClassLoader();
		currentThread.setContextClassLoader(contextClassLoader);
		try {
			migrate();
		} finally {
			currentThread.setContextClassLoader(originalLoader);
		}
	}

        // PASSES always
	@Test
	public void flywayVisibleFromContextLoader() {
		migrateUsing(getClass().getClassLoader());
	}

        // PASSES on 7.7.1, FAILS on 7.8.2
	@Test
	public void flywayNotVisibleFromContextLoader() {
		ClassLoader emptyLoader = new ClassLoader(null) {};
		migrateUsing(emptyLoader);
	}

	@AfterEach
	public void resetFlywayState() throws NoSuchFieldException, IllegalAccessException {
                // No other good way to do this
		Field field = DatabaseTypeRegister.class.getDeclaredField("hasRegisteredDatabaseTypes");
		field.setAccessible(true);
		field.set(null, false);
	}

}
1reaction
A248commented, May 14, 2021

I ran into this same problem. Unit tests pass but migration fails in the deployment environment. It occurs when Flyway and the user code is in a child ClassLoader, which is unreachable from the context ClassLoader.

On previous versions, in my case 7.7.1, using Flyway.configure(classLoader) works fine and allows Flyway to detect migrations reachable in the specified ClassLoader which are not available in the context ClassLoader.

The issue is that the ServiceLoader.load(Class) uses the context ClassLoader:

https://github.com/flyway/flyway/blob/7f9921a58eb3b35a217e47e3dd1bf9a787386175/flyway-core/src/main/java/org/flywaydb/core/internal/database/DatabaseTypeRegister.java#L54

To solve this, ServiceLoader.load(Class, ClassLoader) can be used instead. It probably should be used instead, considering the context loader is more of a mechanism to workaround inflexible existing APIs (from what I understand).

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlywayException : Unsupported Database: MariaDB 10.5
Does it mean the support of flyway is supported only till mariadb 10.4 version ? Any suggestions/ help. spring-boot · flyway · mariadb-10.5....
Read more >
MariaDB - Flyway by Redgate • Database Migrations Made ...
MariaDB support is a separate dependency for Flyway and will need to be added to your Java project to access these features. MariaDB...
Read more >
Upgrading from MariaDB 10.3 to MariaDB 10.4
How to Upgrade; Incompatible Changes Between 10.3 and 10.4 ... Before you upgrade, it would be best to take a backup of your...
Read more >
Unsupported Database: MariaDB 10.5-Springboot
[Solved]-FlywayException : Unsupported Database: MariaDB 10.5-Springboot ... From Flyway 8.2.1, both MySQL and MariaDB database support has been part of a ...
Read more >
MySQL Governor allows upgrades to unsupported versions of ...
Symptoms MariaDB 10.4 cause issues with loading phpMyAdmin from the cPanel ... Cpanel::Exception::Database::Error/(XID owejf4j) The system ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found