lab bhattacharjee
lab bhattacharjee

Reputation: 1677

Liquibase test hangs and finally fails with Cassandra & TestContainer

Please refer to the sample code here.

I am trying to validate liquibase for Cassandra with test Container (cassandra:5.0) through junit-jupiter.

$ gradle -vV

------------------------------------------------------------
Gradle 8.11.1
------------------------------------------------------------

Build time:    2024-11-20 16:56:46 UTC
Revision:      481cb05a490e0ef9f8620f7873b83bd8a72e7c39

Kotlin:        2.0.20
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM:  21.0.2 (Oracle Corporation 21.0.2+13-58)
Daemon JVM:    D:\unzipped\openjdk-21.0.2_windows-x64_bin\jdk-21.0.2 (no JDK specified, using current Java home)
OS:            Windows 11 10.0 amd64

I could successfully validate liquibase with Postgres with and without Spring : please refer to LabSpringtestContainer and LabtestContainer under this.

But with Cassandra, the following method gets executed LockServiceCassandra#isLockedByCurrentInstance and the following lines gets printed:

Feb 03, 2025 4:24:30 PM liquibase.ext
INFO: Waiting for changelog lock....

in each GlobalConfiguration#CHANGELOGLOCK_POLL_RATE (default 1 second)

for liquibase.GlobalConfiguration#CHANGELOGLOCK_WAIT_TIME (default 5 minutes)

Finally the following lines get printed:

 FAILED
    liquibase.exception.CommandExecutionException: liquibase.exception.LockException: Could not acquire change log lock.  Currently locked by UNKNOWN
        at app//liquibase.command.CommandScope.execute(CommandScope.java:258)
        at app//liquibase.Liquibase.lambda$update$0(Liquibase.java:216)
        at app//liquibase.Scope.lambda$child$0(Scope.java:191)
        at app//liquibase.Scope.child(Scope.java:200)
        at app//liquibase.Scope.child(Scope.java:190)
        at app//liquibase.Scope.child(Scope.java:169)
        at app//liquibase.Liquibase.runInScope(Liquibase.java:1329)
        at app//liquibase.Liquibase.update(Liquibase.java:205)
        at app//liquibase.Liquibase.update(Liquibase.java:188)
        at app//liquibase.Liquibase.update(Liquibase.java:175)
        at app//liquibase.Liquibase.update(Liquibase.java:165)
        at app//nosql.CassandraTest.name(CassandraTest.java:141)

FYI, LockDatabaseChangeLogGeneratorCassandra#generateSql generates the update query to lock the row.

But, UnlockDatabaseChangeLogGeneratorCassandra#generateSql is never invoked.

Any help to resolve this issue will be more than welcome!

Upvotes: 0

Views: 32

Answers (0)

Related Questions