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

Liquibase includeall only works in dev mode #14751

Closed
Postremus opened this issue Feb 1, 2021 · 14 comments · Fixed by #15972 or #16293
Closed

Liquibase includeall only works in dev mode #14751

Postremus opened this issue Feb 1, 2021 · 14 comments · Fixed by #15972 or #16293
Labels
area/liquibase kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Milestone

Comments

@Postremus
Copy link
Member

Describe the bug
I want to use includeAll in my changelog to include all other changelog files in a specific directory. This works in dev mode just fine.
When I run this project as jar however, the changelog in the directory is not executed / found.

 <includeAll path="1.0.0/" relativeToChangelogFile="true"/>

Replacing the includeAll with a simple include works in dev mode and when run as jar.

<include file="1.0.0/001-create-table-setting_group.xml" relativeToChangelogFile="true"/>

Expected behavior
As seen from this dev mode run, the changeset that gets executed is actually printed as console output:

2021-02-01 22:19:11,548 INFO  [liq.changelog] (Quarkus Main Thread) Reading resource: db/1.0.0/001-create-table-setting_group.xml
2021-02-01 22:19:11,770 INFO  [liq.lockservice] (Quarkus Main Thread) Successfully acquired change log lock
2021-02-01 22:19:11,779 INFO  [liq.changelog] (Quarkus Main Thread) Reading resource: db/1.0.0/001-create-table-setting_group.xml
2021-02-01 22:19:11,804 INFO  [liq.changelog] (Quarkus Main Thread) Creating database history table with name: PUBLIC.DATABASECHANGELOG
2021-02-01 22:19:11,806 INFO  [liq.changelog] (Quarkus Main Thread) Reading from PUBLIC.DATABASECHANGELOG
2021-02-01 22:19:11,825 INFO  [liq.changelog] (Quarkus Main Thread) Table setting_group created
2021-02-01 22:19:11,825 INFO  [liq.changelog] (Quarkus Main Thread) ChangeSet db/1.0.0/001-create-table-setting_group.xml::MPPN-300-create-table-setting_group::postremus ran successfully in 3ms
2021-02-01 22:19:11,829 INFO  [liq.changelog] (Quarkus Main Thread) Unique constraint added to setting_group(type,group_key)
2021-02-01 22:19:11,829 INFO  [liq.changelog] (Quarkus Main Thread) ChangeSet db/1.0.0/001-create-table-setting_group.xml::MPPN-300-create-constraints-setting_group::postremus ran successfully in 2ms
2021-02-01 22:19:11,830 INFO  [liq.lockservice] (Quarkus Main Thread) Successfully released change log lock
2021-02-01 22:19:11,936 INFO  [io.quarkus] (Quarkus Main Thread) lq-includeall 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.11.1.Final) started in 1.290s. Listening on: http://localhost:8080
2021-02-01 22:19:11,937 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.

Actual behavior
The changeset is not executed, as seen from this run as jar. Note that the changeset is not even printed, indecating that it was not found.

2021-02-01 22:17:01,084 INFO  [liq.lockservice] (main) Successfully acquired change log lock
2021-02-01 22:17:01,118 INFO  [liq.changelog] (main) Creating database history table with name: PUBLIC.DATABASECHANGELOG
2021-02-01 22:17:01,120 INFO  [liq.changelog] (main) Reading from PUBLIC.DATABASECHANGELOG
2021-02-01 22:17:01,146 INFO  [liq.lockservice] (main) Successfully released change log lock
2021-02-01 22:17:01,325 INFO  [io.quarkus] (main) lq-includeall 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.11.1.Final) started in 1.086s. Listening on: http://0.0.0.0:8080
2021-02-01 22:17:01,326 INFO  [io.quarkus] (main) Profile prod activated. 

To Reproduce

Steps to reproduce the behavior:

  1. Download the reproducer: lq-includeall.zip
  2. mvn quarkus:dev. The changet is executed.
  3. mvn clean install. cd target/.java -jar lq-includeall-1.0.0-SNAPSHOT-runner.jar . The changeset is not executed.
  4. Now, go to the db/changeLog.xml file, and replace the includeAll with the commented out include. Repeat steps 2 and 3. Both of them now execute the changeset.

Configuration

quarkus.datasource.username=sa
quarkus.datasource.jdbc.url=jdbc:h2:mem:test
quarkus.datasource.db-kind=h2
quarkus.liquibase.migrate-at-start=true

Environment (please complete the following information):
Output of uname -a or ver:
Linux martin 5.8.0-41-generic #46~20.04.1-Ubuntu SMP Mon Jan 18 17:52:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version:
openjdk 11.0.7 2020-04-14 LTS
OpenJDK Runtime Environment Zulu11.39+15-CA (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.39+15-CA (build 11.0.7+10-LTS, mixed mode)
Quarkus version or git rev:
1.11.1.Final
Build tool (ie. output of mvnw --version or gradlew --version):
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/martin/.sdkman/candidates/maven/current
Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: /home/martin/.sdkman/candidates/java/11.0.7-zulu
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-41-generic", arch: "amd64", family: "unix"

@Postremus Postremus added the kind/bug Something isn't working label Feb 1, 2021
@ghost
Copy link

ghost commented Feb 1, 2021

/cc @andrejpetras, @geoand, @gsmet

@famod
Copy link
Member

famod commented Feb 2, 2021

Hm, I tried a few Quarkus versions (down to 1.9.2) and I even tried switching off relativeToChangelogFile but nothing helped.
But then I went back as far as 1.7.5.Final and with that version it still works! So it broke in 1.8.0.CR1, most likely due to #11147 (the update to Liquibase 4), but I haven't bisected it.

There are quite a few open issues in Liquibase for includeAll(), e.g. liquibase/liquibase#1436

@jglink does it still work for you? (saw your comment here: liquibase/liquibase#1436 (comment))

@famod
Copy link
Member

famod commented Feb 2, 2021

PS @geoand: Strange that the test you introduced back in june still works: #9881

@geoand
Copy link
Contributor

geoand commented Feb 2, 2021

Very weird indeed...

@famod
Copy link
Member

famod commented Feb 2, 2021

I've added my findings to liquibase/liquibase#1436 (comment).
Unless @stuartwdouglas comes up with some classloading black magic to work around the problem, I guess we have to wait until someone fixes the problem upstream.

@stuartwdouglas
Copy link
Member

Nope, that is a production app that is using the JDK ClassLoader, nothing Quarkus related.

@jglink
Copy link

jglink commented Feb 3, 2021

@famod The 'includeAll' worked for me with Quarkus 1.10.x which I think used Liquibase 4.1.1
After the upgrade to Quarkus 1.11.x and therefore Liquibase 4.2.2 it fails again.

@famod
Copy link
Member

famod commented Feb 3, 2021

@jglink Ok thanks. I've already tried 1.9.2 with Liquibase 4.1.1 but it did fix the problem. Strange.

@famod famod added triage/upstream Used for issues which are caused by issues in upstream projects/dependency and removed area/devmode labels Feb 5, 2021
@nvoxland
Copy link

I was able to reproduce the issue and have an upcoming fix in Liquibase to handle it.

liquibase/liquibase#1688

@famod
Copy link
Member

famod commented Feb 11, 2021

Awesome, thanks @nvoxland! Fingers crossed it ends up in 4.3.1. 😉

@nvoxland
Copy link

We were already in the final testing for 4.3.1 (quick release to address a breaking issue), so it will be 4.3.2, unfortunately.

@famod
Copy link
Member

famod commented Mar 24, 2021

Good news: This is fixed in main for JVM mode after upgrading to Liquibase 4.3.2 via #15972. This will be part of 1.13.1.Final.

I don't think it will work properly in native mode. I think we'll have to add support to the liquibase extension.
I'll try to have a look before 1.13.1 is released.
/cc @gsmet

@famod famod linked a pull request Mar 24, 2021 that will close this issue
@famod
Copy link
Member

famod commented Mar 28, 2021

So, I have to confirm that it's not working in native mode (I extended the IT locally).

@gsmet @andrejpetras AFAICS, the included files are picked up here and end up in the native app:
https://github.com/quarkusio/quarkus/blob/1.13.0.Final/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java#L349
But I suppose it then fails to find them in this execution branch: https://github.com/liquibase/liquibase/blob/v4.3.2/liquibase-core/src/main/java/liquibase/resource/ClassLoaderResourceAccessor.java#L278
This is just an assumption, since I have never debugged in native mode.
I'm a bit lost at this point and I don't have much time to spend on this so any help would be appreciated!

@famod
Copy link
Member

famod commented Apr 6, 2021

I created a separate issue for native: #16292

gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 7, 2021
Resolves quarkusio#14751 by verifying that Liquibase upgrade in quarkusio#15972 fixed (it in JVM mode)

(cherry picked from commit 153161c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/liquibase kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants