Git Product home page Git Product logo

liquibase-sessionlock's Introduction

Liquibase Extension: Session Lock Support

Provides session-level (vs. transaction-level) LockService implementations. Session-level locks get automatically released if the database connection drops, and overcome the shortcoming of the StandardLockService:

If Liquibase does not exit cleanly, the lock row may be left as locked. You can clear out the current lock by running liquibase releaseLocks which runs UPDATE DATABASECHANGELOGLOCK SET LOCKED=0.

Running liquibase releaseLocks in a micro-service production environment may not be really feasible.

Supported Databases

  • MySQL
  • MariaDB
  • PostgreSQL
  • Oracle

Support for other databases may be conveniently added by extending SessionLockService.

MySQL / MariaDB

The MySQL and MariaDB implementation rely on user locks: get_lock and is_used_lock are builtin functions for MySQL and MariaDB. The lock is automatically released when the connection is dropped unexpectedly.

PostgreSQL

The Postgres implementation used pg_try_advisory_lock and pg_try_advisory_unlock

Oracle

The Oracle implementation relies on DBMS_LOCK. The user that executes liquibase must have EXECUTE privilege on DBMS_LOCK.

grant execute on SYS.DBMS_LOCK to <user>;

To read lock information, the user needs permissions to read from V$LOCK and V$SESSION.

grant select on SYS.V_$LOCK to <user>;
grant select on SYS.V_$SESSION to <user>;

Usage

To use the new lockservice, simply add a dependency to the library. Because the priority is higher than the StandardLockService, it will automatically be used (provided the database is supported). The library supports Liquibase v3.x and v4.x.

Maven

<dependency>
    <groupId>com.github.blagerweij</groupId>
    <artifactId>liquibase-sessionlock</artifactId>
    <version>1.4.0</version>
</dependency>

Gradle

implementation 'com.github.blagerweij:liquibase-sessionlock:1.4.0'

Disclaimer

This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

License

This module is using the Apache Software License, version 2.0. See http://www.apache.org/licenses/LICENSE-2.0.txt

liquibase-sessionlock's People

Contributors

anessi avatar blagerweij avatar stanio avatar turbanoff avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.