# CustomChange executed twice: integration with python

**URL:** <https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946>\
**Category:** General Discussion\
**Created:** [March 21, 2023, 12:49pm UTC](https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946 "2023-03-21T12:49:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergdev](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@sergdev](https://forum.liquibase.org/u/sergdev)\
**Post date:** [March 21, 2023, 12:49pm UTC](https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946/1 "2023-03-21T12:49:06Z")

</div>

Hello guys.  
I have a python project and for database migrations we use liquibase. For database migrations I wrote simple Java class that executes some python script with parameter from migration.  
Example of the xml file with migration:

```auto
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
    <changeSet id="2" author="sergii_glazyrin">
        <customChange class="proj.ExecutePythonMigration">
            <param name="command" value="create-system-user"/>
        </customChange>
        <rollback></rollback>
    </changeSet>
</databaseChangeLog>

```

and this ExecutePythonMigration is the implementation of the CustomTaskChange interface:

```auto

public class ExecutePythonMigration implements CustomTaskChange {
      ...............
}

```

But method execute in this ExecutePythonMigration executed twice. I debugged it, removed everything from execute method. And just kept there logging of the severe message to understand how many times this method was executed. And I’ve got this debug message twice.

Liquibase version: 4.20  
DB: postgres  
Liquibase properties file:

```auto
changeLogFile=liquibase/root.yml
liquibase.command.url=jdbc:postgresql://127.0.0.1:5432/db
liquibase.command.username=sglazyrin
liquibase.command.password=123456
classpath=liquibase/java-migrations/proj-migration/target/proj-migration-1.0-SNAPSHOT.jar

```

What could be wrong ?  
Do you need more information to track down this issue ?

---

<div class="post-metadata">

**Author:** ![mlmehta](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mlmehta](https://forum.liquibase.org/u/mlmehta)\
**Post date:** [March 23, 2023, 10:50am UTC](https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946/2 "2023-03-23T10:50:09Z")

</div>

We are facing the same issue on upgrade of Liquibase from 3.10.3 to 4.20.0.

Looking through the code, it seems that the ChangeSet.execute(…) method has added a call to addSqlMdc(…) which is triggering the additional invocation of generateStatements method if you have extended CustomTaskChange class

---

<div class="post-metadata">

**Author:** ![sergdev](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@sergdev](https://forum.liquibase.org/u/sergdev)\
**Post date:** [March 23, 2023, 2:33pm UTC](https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946/3 "2023-03-23T14:33:23Z")

</div>

hello, thanks for the reply. Is there any workaround for this ?

---

<div class="post-metadata">

**Author:** ![mlmehta](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mlmehta](https://forum.liquibase.org/u/mlmehta)\
**Post date:** [March 24, 2023, 2:28am UTC](https://forum.liquibase.org/t/customchange-executed-twice-integration-with-python/7946/4 "2023-03-24T02:28:47Z")

</div>

Sergdev,

We have downgraded to v4.17.2 to resolve this issue.

The method call to “addSqlMdc” which is calling the duplicate invocation of generateStatements(…) was added in version 4.19.1

You can try 4.19.0 or 4.18.0 also if you are looking for specific features introduced in either of these versions  
Regards  
Milan
