quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Property [autoIncrement] was not found for object type [liquibase.datatype.core.BigIntType] #42928

Closed vladimirfx closed 2 months ago

vladimirfx commented 2 months ago

Describe the bug

Liquibase crashed at runtime after the upgrade from 3.13.3 to 3.14.1.

Expected behavior

Libquibase changes should applied normally.

Actual behavior

Changeset fragment:

            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>

Stacktrace:

 [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] 2024-08-31 09:31:28,050 ERROR [io.qua.run.Application] (main) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.Application.start(Application.java:101)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:119)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runner.GeneratedMain.main(Unknown Source)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] Caused by: java.lang.IllegalStateException: Error starting Liquibase
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.liquibase.runtime.LiquibaseRecorder.doStartActions(LiquibaseRecorder.java:93)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.deployment.steps.LiquibaseProcessor$startLiquibase1744275855.deploy_0(Unknown Source)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.deployment.steps.LiquibaseProcessor$startLiquibase1744275855.deploy(Unknown Source)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  ... 7 more
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] Caused by: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.UnexpectedLiquibaseException: Property [autoIncrement] was not found for object type [liquibase.datatype.core.BigIntType]
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.command.CommandScope.execute(CommandScope.java:258)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Liquibase.lambda$validate$24(Liquibase.java:1247)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.lambda$child$0(Scope.java:191)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:200)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:190)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:169)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Liquibase.runInScope(Liquibase.java:1290)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Liquibase.validate(Liquibase.java:1242)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.liquibase.runtime.LiquibaseRecorder.doStartActions(LiquibaseRecorder.java:82)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  ... 9 more
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] Caused by: liquibase.exception.LiquibaseException: liquibase.exception.UnexpectedLiquibaseException: Property [autoIncrement] was not found for object type [liquibase.datatype.core.BigIntType]
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:148)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:381)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.command.core.helpers.DatabaseChangelogCommandStep.run(DatabaseChangelogCommandStep.java:92)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.command.CommandScope.execute(CommandScope.java:220)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  ... 17 more
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] Caused by: liquibase.exception.UnexpectedLiquibaseException: Property [autoIncrement] was not found for object type [liquibase.datatype.core.BigIntType]
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.util.ObjectUtil.setProperty(ObjectUtil.java:128)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.datatype.DataTypeFactory.fromDescription(DataTypeFactory.java:251)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.change.core.CreateTableChange.generateStatements(CreateTableChange.java:101)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.change.AbstractChange.generateStatementsVolatile(AbstractChange.java:352)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector] Exception in thread "Shutdown thread" java.lang.NullPointerException
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.change.AbstractChange.warn(AbstractChange.java:423)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.visitor.ValidatingVisitor.validateChange(ValidatingVisitor.java:159)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.visitor.ValidatingVisitor.visit(ValidatingVisitor.java:119)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:455)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.ChangeLogIterator.lambda$run$0(ChangeLogIterator.java:131)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.lambda$child$0(Scope.java:191)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:200)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:190)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:169)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.ChangeLogIterator.lambda$run$1(ChangeLogIterator.java:120)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.lambda$child$0(Scope.java:191)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:200)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:190)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:169)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:257)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.Scope.child(Scope.java:261)
      > [cdr-log-collector-7b85bc6fc4-c9kxz cdr-log-collector]  at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:89)

How to Reproduce?

No response

Output of uname -a or ver

K8s 1.30.1

Output of java -version

21.0.4+7-LTS

Mandrel or GraalVM version (if different from Java)

Mandrel-23.1.4.0-Final

Quarkus version or git rev

3.14.1

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.10

Additional information

Workaround:

@RegisterForReflection(targets = [BigIntType::class])
quarkus-bot[bot] commented 2 months ago

/cc @Karm (mandrel), @andrejpetras (liquibase), @galderz (mandrel), @geoand (liquibase), @gsmet (liquibase), @zakkak (mandrel)

gsmet commented 2 months ago

@gcw-it would you be interested in having a look? looks like we need to add more reflection but it would be nice to understand if it’s all that’s needed or if we missed something else?

gcw-it commented 2 months ago

@gsmet I'll have a look.

Since there seems to be no plan by the liquibase team, to support GraalVM directly for the foreseeable future, there is no other way, than to keep supporting native images containing liquibase downstream for the time being.

There is a json file in a PR in the graalvm-support branch that lists the classes that should be registered for reflection.

I'll compare it to what we already have, to determine, what we possibly need to register beyond that.

gsmet commented 2 months ago

@gcw-it I had a quick look as it's a bit time sensitive and I would like it to be fixed for 3.14.2 (and I need the fix merged by tomorrow evening).

My current line of thinking is that it's related to https://github.com/quarkusio/quarkus/pull/42308/files and that before this patch, we were registering all the services for constructors AND methods and now we only do it for constructors (because that what the service provider does). So I think we need to do something similar to what we do with Precondition but I think only registering methods should be enough.

Do you think you can get a fix by tomorrow? If not, I'll push a quick fix. I perfectly understand if not, I just don't want to step on your toes.

gcw-it commented 2 months ago

@gsmet The culprit is the autoincrement attribute of the BigIntType. The liquibase data types are all registered via the service providers, but only for the constructors. Additionally registering the methods for reflection solves this issue.

I already have locally a fixed version, I'm just running a couple of tests, to verify all is working properly. You'll have a PR today.

gsmet commented 2 months ago

Oh, that's awesome, thanks! Let's make sure we add the autoIncrement thing to the IT!

gcw-it commented 2 months ago

Already done.

I'm evaluating, if similar tests can be included for the remaining data types.

gsmet commented 2 months ago

@vladimirfx thanks for the report, this will get fixed in 3.14.2 that we will release tomorrow.