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 update fails for DB2 in version 4.7.0 #2360

Closed
MarcusZander-SPayment opened this issue Jan 12, 2022 · 8 comments · Fixed by #2364
Closed

liquibase update fails for DB2 in version 4.7.0 #2360

MarcusZander-SPayment opened this issue Jan 12, 2022 · 8 comments · Fixed by #2364

Comments

@MarcusZander-SPayment
Copy link

Environment

Liquibase Version: 4.7.0
Liquibase Integration & Version: gradle
Liquibase Extension(s) & Version:

  • liquibase-hibernate5:4.7.0,
  • liquibase-gradle-plugin:2.1.1

Database Vendor & Version: IBM DB2 11 (Linux)
Operating System Type & Version: Windows 10

Description

Since the update of liquibase to 4.7.0 in our gradle build these liquibase-gradle tasks throw the same error: update, updateTestingRollback, rollBackCount against DB2. diffChangeLog is working, other where not tested/used.

There was no change to the changeset or build-script. The only thing that changed is the liquibase version (4.6.2 worked fine)

Liquibase is not able to determine the default schema. These messages appear:

  • INFORMATION [liquibase.database] Cannot check pg_settings
  • INFORMATION [liquibase.database] Error getting default schema

The problem is: Liquibase tries to read from a table PG_SETTINGS which does not exist. Googling yields that this table belongs to PosgreSQL databases, but we use IBM DB2, so I suppose our database is wrongly classified as a PosgreSQL.
See "Actual Behavior" for the log.

Steps To Reproduce

gradlew update
or
gradlew updateTestingRollback
or
gradlew rollbackCount -PliquibaseCommandValue=1
or
starting a spring-boot-application with liquibase enabled against DB2

Actual Behavior

The tasks update/updateTestingRollback/rollbackCount fail very early before even one changeset ran. This is reproducable for version 4.7.0 and not for 4.6.2 (working)

Here is the Log:
`
[2022-01-12 12:29:09] INFORMATION [liquibase.database] Cannot check pg_settings
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=REDACTED.PG_SETTINGS, DRIVER=4.25.13
at com.ibm.db2.jcc.am.b6.a(b6.java:810)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:140)
at com.ibm.db2.jcc.am.k3.c(k3.java:2824)
at com.ibm.db2.jcc.am.k3.d(k3.java:2808)
at com.ibm.db2.jcc.am.k3.a(k3.java:2234)
at com.ibm.db2.jcc.t4.ab.i(ab.java:206)
at com.ibm.db2.jcc.t4.ab.b(ab.java:96)
at com.ibm.db2.jcc.t4.p.a(p.java:32)
at com.ibm.db2.jcc.t4.av.i(av.java:150)
at com.ibm.db2.jcc.am.k3.al(k3.java:2203)
at com.ibm.db2.jcc.am.k3.a(k3.java:3330)
at com.ibm.db2.jcc.am.k3.a(k3.java:737)
at com.ibm.db2.jcc.am.k3.executeQuery(k3.java:716)
at liquibase.database.core.PostgresDatabase.setConnection(PostgresDatabase.java:176)
at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:121)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:92)
at liquibase.integration.commandline.Main.doMigration(Main.java:1517)
at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:398)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.integration.commandline.Main$1.run(Main.java:397)
at liquibase.integration.commandline.Main$1.run(Main.java:221)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.Main.run(Main.java:221)
at liquibase.integration.commandline.Main.main(Main.java:164)

[2022-01-12 12:29:09] INFORMATION [liquibase.database] Error getting default schema
liquibase.exception.DatabaseException: Error executing SQL select current_schema(): DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=END-OF-STATEMENT;ect current_schema();<table_expr>, DRIVER=4.25.13
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:126)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:161)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:172)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:180)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:195)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:190)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:365)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:325)
at liquibase.changelog.ChangeLogParameters.(ChangeLogParameters.java:61)
at liquibase.Liquibase.(Liquibase.java:119)
at liquibase.integration.commandline.Main.doMigration(Main.java:1677)
at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:398)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.integration.commandline.Main$1.run(Main.java:397)
at liquibase.integration.commandline.Main$1.run(Main.java:221)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.Main.run(Main.java:221)
at liquibase.integration.commandline.Main.main(Main.java:164)
`

Expected/Desired Behavior

Liquibase should determine the schema on DB2 like it could in version 2.6.2 so that the tasks update/updateTestingRollback... can be used again.

Additional Context

We use liquibase integrated with gradle on our delevopment-PCs against a DB2 on Linux. The problem occured while starting a spring-boot-app wich uses the auto-update-feature from liquibase and is reproducible (see above) on the gradle command line. (Liquibase-CLI was not tested)

@molivasdat
Copy link
Contributor

Hi @MarcusZander-SPayment Thanks for posting this issue. What version of DB2 on Linux are you running? And can you add a loglevel=FINE based log for us to use to possibly figure out what is causing this issue?

@MarcusZander-SPayment
Copy link
Author

@molivasdat We are using DB2 v11.1.4.6 = Version 11.1 Fixpack 6 on Linux.
The complete log with loglevel FINE is attached. (Some parts are replaced by "REDACTED")
gradlewUpdate_FINE.log

The first error is "Cannot check pg_settings" because the Table PG_SETTINGS doesn't exist. (It was not nessesary until now)
This error is followed by errors that occur everytime when the default schema is to be used "Error getting default schema". It seems the SQL-Statement doesn't work on DB2.

Are there migration steps to take from 4.6.2 to 4.7 that we missed?

@nvoxland
Copy link
Contributor

I see the problem. If your hostname or database has an "edb" in it, our logic for detecting EnterpriseDB is to broad.

This is fixed by #2364

@nvoxland nvoxland linked a pull request Jan 13, 2022 that will close this issue
@nvoxland
Copy link
Contributor

I added a work-around to the PR's description

@MarcusZander-SPayment
Copy link
Author

MarcusZander-SPayment commented Jan 14, 2022

@nvoxland Thank you for the workaround setting the database dialect, but it does not work for us.
Using the liquibase.properties is no option in our scenario because we use another DB type for testing (H2).

Using the liquibase-gradle-plugin this can also be done this way:
build.gradle:

liquibase {
activities {
main {
databaseClass 'liquibase.database.core.DB2Database'
// ... other entries
}
}
runList = 'main'
}

That solves the problem for calling liquibase from the gradle build.
But the gradle update is also used in our app when the application starts using the spring boot autoconfig for liquibase.
In detail: entries below the prefix 'spring.liquibase' get mapped to the bean org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.
And that class is missing a field for databaseClass, so that the workaround sadly dont work for us.

@molivasdat molivasdat added this to To Do in Conditioning++ via automation Jan 14, 2022
Conditioning++ automation moved this from To Do to Done Jan 20, 2022
@nvoxland nvoxland removed this from Done in Conditioning++ Jan 21, 2022
@nvoxland nvoxland added this to the v4.7.1 milestone Jan 21, 2022
@kataggart
Copy link
Contributor

@MarcusZander-SPayment release v.4.7.1 is out now and the fix to this is included. Thanks!

@MarcusZander-SPayment
Copy link
Author

Thank you guys for your time and the quick sollution!

@kataggart
Copy link
Contributor

You are most welcome! By the way, @MarcusZander-SPayment if you have ideas you'd like to see implemented, please check out the post here in the forum and we'd love to see you at the next Meetup on Feb 10 to talk more about future planning.

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