cryptomator / cryptomator/hub

Quarkus hot reloading fails due to missing Flyway migration

Open
#212 2 comments 0 reactions 0 assignees View on GitHub
component:backend
Dominant language
Java
Stars
80
Forks
15
PR merge metrics
No merged PRs in 30d

Description

### Please agree to the following

- [X] I have searched [existing issues](https://github.com/cryptomator/hub/issues?q=) for duplicates
- [X] I agree to follow this project's [Code of Conduct](https://github.com/cryptomator/hub/blob/develop/.github/CODE_OF_CONDUCT.md)

### Summary

Hot Reloading fails due to missing V2 migration

### System Setup

```markdown
- 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

```shell
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`](https://github.com/cryptomator/hub/blob/develop/backend/src/main/java/org/cryptomator/hub/flyway/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:

https://github.com/cryptomator/hub/blob/72150eaba3ee6812e1218b1974eb31ee040f902f/backend/src/main/resources/application.properties#L62-L63

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.