Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase in concurrent environment

I'm going to use liquibase as application start plugin in some concurrent environment(clustering or multithread initialization). Is there any guarantee of the correct database update in concurrent environment, which is supported by liquibase library, or i have to do it manually? Thank you!

like image 690
hellraiser Avatar asked Sep 11 '14 10:09

hellraiser


People also ask

Which is better flyway or Liquibase?

While both tools are based on Martin Fowler's Evolutionary Database, there are many differences in what these tools offer. Here's where Liquibase and Flyway differ. The bottom line is that Liquibase is more powerful and flexible — covering more database change and deployment use cases than Flyway.

Can Liquibase migrate data?

Liquibase offers a powerful open source database migration tool for Java apps. It brings structure and confidence to developers and DBAs that need to easily create and track database schema changes.

Why Liquibase is required?

Liquibase allows you to specify the database change you want using SQL or several different database-agnostic formats, including XML, YAML, and JSON. Developers can abstract the database code to make it extremely easy to push out changes to different database types.


1 Answers

Liquibase does implement an exclusive lock, using the ACID transactional features of your RDBMS. This prevents multiple instances of Liquibase from performing schema migrations concurrently. It is accomplished by doing transactional updates to the DATABASECHANGELOGLOCK table that is added to your schema by Liquibase.

However, this mechanism does not prevent other potential concurrency problems that can result from operations not executed directly by Liquibase. Consider the case where one node in a cluster is performing schema migrations and the other nodes are attempting to perform normal business logic with that schema. Other nodes in the cluster see the schema in stable state A, followed by some amount of intermediate variation, and then finally in stable state B. The application must be designed to handle this sort of transition, or there will need to be downtime while a migration occurs.

Similarly, it is the application's responsibility to handle having a mix of older and newer clients (e.g. during a rolling upgrade) where the concept of the "correct" schema version is not unanimously in agreement, if such an environment is required.

like image 75
William Price Avatar answered Oct 12 '22 03:10

William Price