/** Releases whatever locks are on the database change log table */ public void forceReleaseLock() throws LockException, DatabaseException { database.checkDatabaseChangeLogLockTable(); releaseLock(); /*try { releaseLock(); } catch (LockException e) { // ignore ? LogFactory.getLogger().info("Ignored exception in forceReleaseLock: " + e.getMessage()); }*/ }
public boolean acquireLock() throws DatabaseException, LockException { if (hasChangeLogLock) { return true; } Executor executor = ExecutorService.getInstance().getExecutor(database); try { database.rollback(); database.checkDatabaseChangeLogLockTable(); Boolean locked = (Boolean) ExecutorService.getInstance() .getExecutor(database) .queryForObject( new SelectFromDatabaseChangeLogLockStatement("LOCKED"), Boolean.class); if (locked) { return false; } else { executor.comment("Lock Database"); int rowsUpdated = executor.update(new LockDatabaseChangeLogStatement()); if (rowsUpdated > 1) { throw new LockException("Did not update change log lock correctly"); } if (rowsUpdated == 0) { // another node was faster return false; } database.commit(); LogFactory.getLogger().info("Successfully acquired change log lock"); hasChangeLogLock = true; database.setCanCacheLiquibaseTableInfo(true); return true; } } finally { database.rollback(); } }