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

Quarkus hot reloading fails due to missing Flyway migration #212

Open
2 tasks done
overheadhunter opened this issue Jul 13, 2023 · 1 comment
Open
2 tasks done

Quarkus hot reloading fails due to missing Flyway migration #212

overheadhunter opened this issue Jul 13, 2023 · 1 comment
Labels
misc:backend type:bug Something isn't working type:upstream-bug Something isn't working in upstream

Comments

@overheadhunter
Copy link
Member

Please agree to the following

Summary

Hot Reloading fails due to missing V2 migration

System Setup

- Quarkus: 3.0.1.Final
- Flyway: 9.16.3 (transitive via quarkus-flyway)

Steps to Reproduce

  1. Start mvn quarkus:dev
  2. Visit localhost:8080, triggering the initial set of Flyway migrations
  3. Change anything (i.e. add a whitespace in some Java file)
  4. Refresh localhost:8080, triggering a Quarkus reload

Expected Behavior

Flyway validates the database successfully (no migration required)

Actual Behavior

Flyway fails to validate the database: Detected applied migration not resolved locally: 2.

Reproducibility

Always

Relevant Log Output

2023-07-13 13:04:53,002 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (vert.x-worker-thread-1) Failed to start quarkus: io.quarkus.dev.appstate.ApplicationStartException: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:58)
        at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:123)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.restartApp(IsolatedDevModeMain.java:222)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.restartCallback(IsolatedDevModeMain.java:203)
        at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:543)
        at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:441)
        at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:152)
        at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:139)
        at io.vertx.core.impl.ContextBase.lambda$null$0(ContextBase.java:137)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
        at io.vertx.core.impl.ContextBase.lambda$executeBlocking$1(ContextBase.java:135)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:104)
        ... 1 more
Caused by: org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations have failed validation
Detected applied migration not resolved locally: 2.
If you removed this migration intentionally, run repair to mark the migration as deleted.
Need more flexibility with validation rules? Learn more: https://rd.gt/3AbJUZE
        at org.flywaydb.core.Flyway.lambda$migrate$0(Flyway.java:146)
        at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:196)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:140)
        at io.quarkus.flyway.runtime.FlywayRecorder.doStartActions(FlywayRecorder.java:93)
        at io.quarkus.deployment.steps.FlywayProcessor$startActions2035800939.deploy_0(Unknown Source)
        at io.quarkus.deployment.steps.FlywayProcessor$startActions2035800939.deploy(Unknown Source)
        ... 11 more

Anything else?

The V2 migration is our deprecated Java-based migration (V2__Initialize_Settings.java). Other than the SQL-based migrations, this seems to be invisible during a hot reload.

Related to #183 and #184

This is our config:

quarkus.flyway.migrate-at-start=true
quarkus.flyway.locations=classpath:org/cryptomator/hub/flyway

@overheadhunter overheadhunter added type:bug Something isn't working misc:backend labels Jul 13, 2023
@overheadhunter overheadhunter added the type:upstream-bug Something isn't working in upstream label Jul 13, 2023
@overheadhunter
Copy link
Member Author

For the record, when setting %dev.quarkus.flyway.ignore-missing-migrations=true, hot reloading works again. But the logs confirm, that V2 is indeed not found:

These are migrations on first start:

2023-07-13 14:55:45,416 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Current version of schema "public": << Empty Schema >>
2023-07-13 14:55:45,430 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "1 - Create Tables"
2023-07-13 14:55:45,499 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "2 - Initialize Settings"
2023-07-13 14:55:45,537 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "3 - Initialize Settings"
2023-07-13 14:55:45,577 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "4 - Update PKs"
2023-07-13 14:55:45,676 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "5 - UTC Timestamps"
...

and after hot reloading, V2 is simply missing:

2023-07-13 14:56:44,857 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Current version of schema "public": << Empty Schema >>
2023-07-13 14:56:44,872 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "1 - Create Tables"
2023-07-13 14:56:44,966 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "3 - Initialize Settings"
2023-07-13 14:56:45,010 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "4 - Update PKs"
2023-07-13 14:56:45,130 INFO  [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "public" to version "5 - UTC Timestamps"
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
misc:backend type:bug Something isn't working type:upstream-bug Something isn't working in upstream
Projects
None yet
Development

No branches or pull requests

1 participant