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

Log the exception in case of failure in ChangeSet.execute #5452

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

bignoncedric
Copy link
Contributor

Fixes #5451

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

If an error occurs a change execution while using Sprint Boot integration, the exception that can be logged is hidden in a 6-8 deep exception stack making the debugging of such error very difficult, especially when used in production with logs truncated to few thousand characters.

This Pull Requests adds the exception as part of the SEVERE log to ensure we have a concise version of the error.

Things to be aware of

Things to worry about

Additional Context

Fixes liquibase#5451

Signed-off-by: Cédric Bignon <bignon.cedric@gmail.com>
Copy link
Contributor

@MalloD12 MalloD12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Even though I wasn't able to reproduce #5451 by executing the below changeset in a completely clean DB:

<changeSet id="createTableNamedPKRef" author="nvoxland">
        <dropTable tableName="createtablenamedpkref"/>
    </changeSet>

I got the below error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: liquibase.exception.MigrationFailedException: Migration failed for changeset changelog/changelog.xml::createTableNamedPKRef::nvoxland:
     Reason: liquibase.exception.DatabaseException: ERROR: table "createtablenamedpkref" does not exist [Failed SQL: (0) DROP TABLE public.createtablenamedpkref]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.9.jar:6.0.9]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1156) ~[spring-context-6.0.9.jar:6.0.9]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:931) ~[spring-context-6.0.9.jar:6.0.9]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.9.jar:6.0.9]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[spring-boot-3.1.0.jar:3.1.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[spring-boot-3.1.0.jar:3.1.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-3.1.0.jar:3.1.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0.jar:3.1.0]

But I think this change doesn't hurt so that's why I think we can move ahead anyway with this PR.

Thanks,
Daniel.

@bignoncedric
Copy link
Contributor Author

bignoncedric commented Jan 22, 2024

Thanks @MalloD12.
The repro steps may be more complex than the ones I provided to get the exact same exception. And probably heavily depends on the state of the DI.

How do I proceed with the merge of this Pull Request?

@MalloD12
Copy link
Contributor

Thanks @MalloD12. The repro steps may be more complex than the ones I provided to get the exact same exception. And probably heavily depends on the state of the DI.

How do I proceed with the merge of this Pull Request?

Hi @bignoncedric.

It still needs to be reviewed by one other developer and reviewed/tested by the QA team before moving this PR to the "Ready to Merge" stage.

Thanks,
Daniel.

@filipelautert filipelautert merged commit b0b1cf0 into liquibase:master Jan 22, 2024
30 of 31 checks passed
@filipelautert filipelautert added this to the 1NEXT milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

With Spring Boot integration, errors happening during changeset execution are not easily debuggable
4 participants