FINERACT-2181: Liquibase migrations are stuck when multi-threaded migrations are enabled and one tenant migration fails

This commit is contained in:
Arnold Galovics
2025-03-06 19:36:34 +01:00
committed by Arnold Gálovics
parent f8e5d6c9fc
commit 7b45f3e4d5
2 changed files with 13 additions and 7 deletions
@@ -148,16 +148,23 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
}
}
List<Exception> exceptions = new ArrayList<>();
try {
for (Future<String> future : futures) {
future.get();
}
} catch (InterruptedException | ExecutionException exception) {
throw new RuntimeException(exception);
exceptions.add(exception);
} finally {
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() {
@@ -193,6 +200,8 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
tenant.getTenantIdentifier());
tenantLiquibase.afterPropertiesSet();
log.info("Upgrade for tenant {} has finished", tenant.getTenantIdentifier());
} catch (Exception e) {
throw new RuntimeException("Exception while upgrading tenant " + tenant.getTenantIdentifier(), e);
}
}