Liquibase chooses wrong Database implementation in version 4.7.0
See original GitHub issueEnvironment
Liquibase Version: 4.7.0
Liquibase Integration & Version: CLI
Liquibase Extension(s) & Version: -
Database Vendor & Version: Azure SQL Database v12.0.2000.8
Operating System Type & Version: Ubuntu 18.04
Description
We recently started using Liquibase using the Docker image, we used the latest tag which resolved to Liquibase v4.7.0. We run the Liquibase container against multiple environments (Dev/Prod/etc) and some environments would consistently fail while others consistently succeeded. The commands were similar because we use a template, with only configuration (ip, username’s) differing according to the environment.
It would fail with the error message saying:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'FALSE'.
Even though the correct driver is being used (as shown in the logs below), Liquibase seems to be using PostgreSQL syntax. If googling for “pg_settings” it seems to be a PostgreSQL thing. Also, FALSE/TRUE seem to be PostgreSQL reserved keywords, that’s why Liquibase is trying to use FALSE/TRUE without quotations, this doesn’t work in MSSQL.
Steps To Reproduce
Run the Liquibase update command using version 4.7.0. We didn’t figure out why it would succeed on some environments and fail on others.
Actual Behavior
Liquibase would fail even before applying our changesets, these errors would only be visible after using --log-level=INFO
:
Log of Liquibase failing to find “pg_settings”:
[2022-01-13 10:34:55] INFO [liquibase.database] Cannot check pg_settings
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'pg_settings'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1632)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:872)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:767)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7375)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3200)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:692)
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.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:32)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:325)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:291)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:80)
Log of Liquibase failing to call a non-existent MSSQL function:
[2022-01-13 10:34:55] INFO [liquibase.database] Error getting default schema
liquibase.exception.DatabaseException: Error executing SQL select current_schema(): 'current_schema' is not a recognized built-in function name.
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:126)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:161)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:325)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:291)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:80)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 'current_schema' is not a recognized built-in function name.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1632)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:602)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:524)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7375)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3200)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:446)
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:498)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:119)
... 36 more
And finally, Liquibase running a syntactical incorrect MSSQL statement:
Unexpected error running Liquibase: Error executing SQL UPDATE databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'REDACTED (172.17.0.5)', LOCKGRANTED = '2022-01-13 10:34:56.274' WHERE ID = 1 AND LOCKED = FALSE: Invalid column name 'FALSE'.
liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: Error executing SQL UPDATE databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'ecbcf27073d2 (172.17.0.5)', LOCKGRANTED = '2022-01-13 10:34:56.274' WHERE ID = 1 AND LOCKED = FALSE: Invalid column name 'FALSE'.
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:325)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:291)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:80)
Expected/Desired Behavior
As said before, some environments would succeed. Liquibase correctly executed the changesets. This is the kind of logging we would have expected on the failing environments:
Starting Liquibase at 10:33:58 (version 4.7.0 #1140 built at 2022-01-07 19:26+0000)
Liquibase Version: 4.7.0
Liquibase Community 4.7.0 by Liquibase
[2022-01-13 10:33:59] INFO [liquibase.database] Set default schema name to REDACTED
[2022-01-13 10:33:59] INFO [liquibase.lockservice] Successfully acquired change log lock
[2022-01-13 10:34:00] INFO [liquibase.changelog] Reading from DATABASECHANGELOG
[2022-01-13 10:34:00] INFO [liquibase.lockservice] Successfully released change log lock
[2022-01-13 10:34:00] INFO [liquibase.lockservice] Successfully acquired change log lock
Skipping auto-registration
[2022-01-13 10:34:00] WARNING [liquibase.hub] Skipping auto-registration
[2022-01-13 10:34:00] INFO [liquibase.lockservice] Successfully released change log lock
Liquibase command 'update' was executed successfully.
Additional Context
We solved this issue by using Liquibase version v4.6.2 for now, this version gives us no problems and all of our changesets are executed succesfully. We changed the docker latest
tag to 4.6.2
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
@M-Koers release v.4.7.1 is out now and the fix to this is included. Thanks!
I added a work-around to the PR’s description