FINERACT-2181: Liquibase migrations are stuck when multi-threaded migrations are enabled and one tenant migration fails
This commit is contained in:
committed by
Arnold Gálovics
parent
f8e5d6c9fc
commit
7b45f3e4d5
+11
-2
@@ -148,16 +148,23 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Exception> exceptions = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
for (Future<String> future : futures) {
|
for (Future<String> future : futures) {
|
||||||
future.get();
|
future.get();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | ExecutionException exception) {
|
} catch (InterruptedException | ExecutionException exception) {
|
||||||
throw new RuntimeException(exception);
|
exceptions.add(exception);
|
||||||
} finally {
|
} finally {
|
||||||
tenantUpgradeThreadPoolTaskExecutor.shutdown();
|
tenantUpgradeThreadPoolTaskExecutor.shutdown();
|
||||||
}
|
}
|
||||||
log.info("Tenant upgrades have finished");
|
|
||||||
|
if (exceptions.isEmpty()) {
|
||||||
|
log.info("Tenant upgrades have successfully finished");
|
||||||
|
} else {
|
||||||
|
exceptions.forEach(e -> log.error("Exception: ", e));
|
||||||
|
throw new RuntimeException("Tenant upgrades had exceptions");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThreadPoolTaskExecutor createTenantUpgradeThreadPoolTaskExecutor() {
|
private ThreadPoolTaskExecutor createTenantUpgradeThreadPoolTaskExecutor() {
|
||||||
@@ -193,6 +200,8 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
|
|||||||
tenant.getTenantIdentifier());
|
tenant.getTenantIdentifier());
|
||||||
tenantLiquibase.afterPropertiesSet();
|
tenantLiquibase.afterPropertiesSet();
|
||||||
log.info("Upgrade for tenant {} has finished", tenant.getTenantIdentifier());
|
log.info("Upgrade for tenant {} has finished", tenant.getTenantIdentifier());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Exception while upgrading tenant " + tenant.getTenantIdentifier(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -40,7 +40,6 @@ import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
|||||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.ExtendedSpringLiquibase;
|
import org.apache.fineract.infrastructure.core.service.migration.ExtendedSpringLiquibase;
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.ExtendedSpringLiquibaseFactory;
|
import org.apache.fineract.infrastructure.core.service.migration.ExtendedSpringLiquibaseFactory;
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.SchemaUpgradeNeededException;
|
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.TenantDataSourceFactory;
|
import org.apache.fineract.infrastructure.core.service.migration.TenantDataSourceFactory;
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseStateVerifier;
|
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseStateVerifier;
|
||||||
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService;
|
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService;
|
||||||
@@ -66,7 +65,7 @@ public class LiquibaseStepDefinitions implements En {
|
|||||||
private DataSource tenantStoreDataSource;
|
private DataSource tenantStoreDataSource;
|
||||||
private TenantDatabaseUpgradeService tenantDatabaseUpgradeService;
|
private TenantDatabaseUpgradeService tenantDatabaseUpgradeService;
|
||||||
private List<FineractPlatformTenant> allTenants;
|
private List<FineractPlatformTenant> allTenants;
|
||||||
private SchemaUpgradeNeededException executionException;
|
private RuntimeException executionException;
|
||||||
private HikariDataSource defaultTenantDataSource;
|
private HikariDataSource defaultTenantDataSource;
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
@@ -103,10 +102,8 @@ public class LiquibaseStepDefinitions implements En {
|
|||||||
When("The database migration process is executed", () -> {
|
When("The database migration process is executed", () -> {
|
||||||
try {
|
try {
|
||||||
tenantDatabaseUpgradeService.afterPropertiesSet();
|
tenantDatabaseUpgradeService.afterPropertiesSet();
|
||||||
} catch (SchemaUpgradeNeededException e) {
|
|
||||||
executionException = e;
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
executionException = (SchemaUpgradeNeededException) e.getCause().getCause();
|
executionException = e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user