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

Native Image run issue with XML Changelog quarkus-liquibase #42143

Closed
RafiIsaharov opened this issue Jul 25, 2024 · 8 comments · Fixed by #41928
Closed

Native Image run issue with XML Changelog quarkus-liquibase #42143

RafiIsaharov opened this issue Jul 25, 2024 · 8 comments · Fixed by #41928

Comments

@RafiIsaharov
Copy link

RafiIsaharov commented Jul 25, 2024

I'm facing an issue with quarkus-liquibase, particularly with the XML Changelog.
I noticed an issue on GitHub, which can be found at https://github.com/quarkusio/quarkus/issues/27437, opened in 2022.

Configuration:

quarkus.liquibase.enabled=true
quarkus.liquibase.migrate-at-start=true
quarkus.liquibase.change-log=db/postgres/changelog-master.yml

files : https://github.com/RafiIsaharov/esb-infra/tree/main/src/main/resources/db/postgres

Snapshot of changelog-master.yml:

databaseChangeLog:
  - include:
      file: db/postgres/changelog.001.sql
  - include:
      file: db/postgres/changelog.002.xml
  - include:
      file: db/postgres/changelog.003.sql
  - include:
      file: db/postgres/changelog.004.sql

Snapshot of changelog.002.xml:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">

    <!--changeSet id="1" author="rafi.isaharov">
        <sql>
            ALTER TABLE routes ADD COLUMN timestamp TIMESTAMP;
        </sql>
    </changeSet-->

    <!--changeSet id="2" author="rafi.isaharov">
        <sql>
            ALTER TABLE routes ALTER COLUMN timestamp SET DEFAULT NOW();
        </sql>
    </changeSet-->

    <changeSet id="3" author="rafi.isaharov">
        <sql splitStatements="false">
            <![CDATA[
            -- Create a function to update timestamp on every update
            CREATE OR REPLACE FUNCTION update_timestamp()
            RETURNS TRIGGER AS $$
            BEGIN
                NEW.timestamp = NOW();
            RETURN NEW;
            END;
            $$ LANGUAGE plpgsql;
            ]]>
        </sql>
    </changeSet>

    <changeSet id="4" author="rafi.isaharov">
        <sql splitStatements="false">
            <![CDATA[
            -- Create a trigger to execute update_timestamp function on every update
            CREATE TRIGGER update_routes_timestamp
                BEFORE UPDATE ON routes
                FOR EACH ROW
                EXECUTE FUNCTION update_timestamp();
            ]]>
        </sql>
    </changeSet>

Error Trace:
exception_liquibase_using_changelog_as_xml.txt

Observations:

  • This issue occurs only in the native image, not when running the runnable jar.

  • The application fails to start with this error.

  • Quarkus version: 3.12.3

  • Java version: 17.0.11+7-LTS, vendor version: Oracle GraalVM 17.0.11+7.1

  • Apache Maven 3.9.6

Current Workaround:
To overcome the issue with the XML changelog file, I am converting it into an equivalent SQL file format.

Reproduce the issue:
I've uploaded the code to my GitHub repository, which includes the docker-compose.yaml file for the Postgres database.
You can download and replicate it from the main branch https://github.com/RafiIsaharov/esb-infra.git.

Copy link

quarkus-bot bot commented Jul 25, 2024

/cc @andrejpetras (liquibase), @geoand (liquibase), @gsmet (liquibase), @zakkak (native-image)

@gsmet
Copy link
Member

gsmet commented Jul 25, 2024

@gcw-it could you have a look at this one while you're at it? Maybe it's already fixed by your ongoing PRs?

@gcw-it
Copy link
Contributor

gcw-it commented Jul 25, 2024

@RafiIsaharov You're in luck. PR #41928 fixes your issue. I could reproduce your problem, and with the PR included your application started without problems and ran the Liquibase migrations successfully.

The answer to when the patch will be incorporated into a Quarkus release, will have to be given by @gsmet .

@geoand
Copy link
Contributor

geoand commented Jul 26, 2024

It should be part of the next 3.13 release

@geoand geoand closed this as completed Jul 26, 2024
@geoand geoand added this to the 3.14 - main milestone Jul 26, 2024
@gsmet
Copy link
Member

gsmet commented Jul 26, 2024

Yeah so not 3.13.0 but 3.13.1 released in two weeks.

@gsmet
Copy link
Member

gsmet commented Jul 26, 2024

@gcw-it thanks for checking!

@geoand
Copy link
Contributor

geoand commented Jul 26, 2024

Thanks again @gcw-it for this important fix!

@gcw-it
Copy link
Contributor

gcw-it commented Jul 26, 2024

@gsmet @geoand You're welcome!

@gsmet gsmet modified the milestones: 3.14 - main, 3.13.1 Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants