# Liuibase.executor.ExecutorService is not threadsafe

**URL:** <https://forum.liquibase.org/t/liuibase-executor-executorservice-is-not-threadsafe/4472>\
**Category:** General Discussion\
**Created:** [July 30, 2020, 7:08pm UTC](https://forum.liquibase.org/t/liuibase-executor-executorservice-is-not-threadsafe/4472 "2020-07-30T19:08:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jxz024000](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@jxz024000](https://forum.liquibase.org/u/jxz024000)\
**Post date:** [July 30, 2020, 7:08pm UTC](https://forum.liquibase.org/t/liuibase-executor-executorservice-is-not-threadsafe/4472/1 "2020-07-30T19:08:20Z")

</div>

We are running liquibase concurrently to patch multiple databases using the same migration file. The liquibase version is 3.10.0. The database is Azure Sql. The exception is thrown in liquibase.executor.ExecutorService.getExecutor (line 93). The reason is multiple threads try to populate the none-threadsafe HashMap for the same key. This should be easily fixed by using a ConncurrentHashMap.

```auto
public class ExecutorService {
    private static ExecutorService instance = new ExecutorService();
    private List<Executor> registry = new ArrayList<>();
    private Map<String, Executor> executors = new HashMap<>();

```

Below is the stack trace.

```auto
! java.util.ConcurrentModificationException: null
! at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
! at liquibase.executor.ExecutorService.getExecutor(ExecutorService.java:93)
[script-executor] Script completed with exit code: 1.
! at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:359)
! at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)
! at liquibase.changelog.ChangeLogParameters.<init>(ChangeLogParameters.java:61)
! at liquibase.Liquibase.<init>(Liquibase.java:109)
! at io.dropwizard.migrations.CloseableLiquibase.<init>(CloseableLiquibase.java:21)
! at io.dropwizard.migrations.CloseableLiquibaseWithClassPathMigrationsFile.<init>(CloseableLiquibaseWithClassPathMigrationsFile.java:19)
[go] Task status: failed, took: 43.334s
! at io.dropwizard.migrations.AbstractLiquibaseCommand.openLiquibase(AbstractLiquibaseCommand.java:82)
! at io.dropwizard.migrations.AbstractLiquibaseCommand.run(AbstractLiquibaseCommand.java:67)

```

---

<div class="post-metadata">

**Author:** ![ronak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/ronak/32/221_2.png) [@ronak](https://forum.liquibase.org/u/ronak)\
**Post date:** [August 4, 2020, 8:40pm UTC](https://forum.liquibase.org/t/liuibase-executor-executorservice-is-not-threadsafe/4472/2 "2020-08-04T20:40:58Z")

</div>

Hey @jxz024000! Welcome to the Liquibase community.

Thanks for bringing this issue up. Would you mind logging this issue [here](https://github.com/liquibase/liquibase/issues)?

Primary way to make change in the product is through our github project in the link above, or you can even make a [PR](https://liquibase.jira.com/wiki/spaces/LB/pages/1274904896/How+to+Contribute+Code+to+Liquibase+Core) and we’ll merge your code directly in! The forum here is primarily for discussion on topics.

Thanks!

Ronak
