LiquidBase transaction execution is aborted

32 views Asked by At

When I use yml file to excute some yml files to create and modify on gcp spanner datebase.

Because of Network Interruption, LiquidBase transaction execution is aborted.

Then the liquidbase is locked, I excuted below the sql to delete the lock

delete from DATABASECHANGELOGLOCK where Id=1

I rerun my project and I can successfully get the lock, but I get an error

SpannerAsyncExecutionException: Execution failed for statement: ALTER TABLE sys_role DROP COLUMN status_apply

I guess that the fields have been deleted last time but the statement is aborted. when I re-executed the yml file, the database could not found the field, so I got the error.

Can you give me some advice?

Please tell how to solve this problem

1

There are 1 answers

0
Knut Olav Løite On

DDL operations in Cloud Spanner are not executed in a transaction. That means that when the operation was started in Liquibase and sent to Cloud Spanner, and Liquibase lost connection with Cloud Spanner, the operation continued in the background. It does not need to be committed. That again means that your ALTER TABLE sys_role DROP COLUMN status_apply change has already been applied to the database, and that re-running it will fail.

The best way to fix this is to manually tell Liquibase that the change set has been applied to the database. The mark-next-change-set-ran command should take care of that: https://docs.liquibase.com/commands/change-tracking/mark-next-changeset-ran.html