CustomChange executed twice: integration with python

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:

<?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:


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:

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 ?

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

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

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