liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
199 stars 59 forks source link

Intermittent failures on update task since 3.0.1 #157

Open T00fy opened 4 days ago

T00fy commented 4 days ago

This is directly related to #154

While ./gradlew --no-daemon and ./gradlew --stop do get around this isusue, it still occurs everytime gradle has cached a deamon, and requiring to kill the daemons everytime is cumbersome.

Can this be investigated?

gdonoso94 commented 4 days ago

+1

max-norin commented 1 day ago

Hi!

I have the same problem. The problem occurs after few minutes of gradle deamon inactivity.

I tried running the following code in the LiquibasePlugin.applyTasks method.

def commandDefinition = CommandFactory.getInstance().getCommandDefinition('update')
println("liquibase-plugin: commandDefinition.name=${commandDefinition.name}")
println("liquibase-plugin: commandDefinition.shortDescription=${commandDefinition.shortDescription}")
println("liquibase-plugin: commandDefinition.longDescription=${commandDefinition.longDescription}")
println("liquibase-plugin: commandDefinition.arguments.keySet()=${commandDefinition.arguments.keySet()}")

The first run results are as follows.

liquibase-plugin: commandDefinition.name=[update]
liquibase-plugin: commandDefinition.shortDescription=Deploy any changes in the changelog file that have not been deployed
liquibase-plugin: commandDefinition.longDescription=null
liquibase-plugin: commandDefinition.arguments.keySet()=[changeExecListener, changeExecListenerClass, changeExecListenerPropertiesFile, changelogFile, changelogParameters, contextFilter, database, databaseChangelog, defaultCatalogName, defaultSchemaName, driver, driverPropertiesFile, labelFilter, password, showSummary, showSummaryOutput, skipDatabaseStep, updateNullChecksums, url, username]

After 5 minutes, the results are as follows.

liquibase-plugin: commandDefinition.name=[update]
liquibase-plugin: commandDefinition.shortDescription=Deploy any changes in the changelog file that have not been deployed
liquibase-plugin: commandDefinition.longDescription=null
liquibase-plugin: commandDefinition.arguments.keySet()=[]

For some reason, commandDefinition.arguments becomes empty after a few minutes of inactivity.

I also run the following code in the LiquibasePlugin.applyTasks method.

def commandDefinition = CommandFactory.getInstance().getCommandDefinition('update')
println("liquibase-plugin: commandDefinition.name=${commandDefinition.name}")
println("liquibase-plugin: commandDefinition.shortDescription=${commandDefinition.shortDescription}")
println("liquibase-plugin: commandDefinition.longDescription=${commandDefinition.longDescription}")
println("liquibase-plugin: commandDefinition.arguments.keySet()=${commandDefinition.arguments.keySet()}")

Scope.exit(Scope.getCurrentScope().scopeId)

commandDefinition = CommandFactory.getInstance().getCommandDefinition('update')
println("liquibase-plugin: commandDefinition.name=${commandDefinition.name}")
println("liquibase-plugin: commandDefinition.shortDescription=${commandDefinition.shortDescription}")
println("liquibase-plugin: commandDefinition.longDescription=${commandDefinition.longDescription}")
println("liquibase-plugin: commandDefinition.arguments.keySet()=${commandDefinition.arguments.keySet()}")

Result:

liquibase-plugin: commandDefinition.name=[update]
liquibase-plugin: commandDefinition.shortDescription=Deploy any changes in the changelog file that have not been deployed
liquibase-plugin: commandDefinition.longDescription=null
liquibase-plugin: commandDefinition.arguments.keySet()=[changeExecListener, changeExecListenerClass, changeExecListenerPropertiesFile, changelogFile, changelogParameters, contextFilter, database, databaseChangelog, defaultCatalogName, defaultSchemaName, driver, driverPropertiesFile, labelFilter, password, showSummary, showSummaryOutput, skipDatabaseStep, updateNullChecksums, url, username]
liquibase-plugin: commandDefinition.name=[update]
liquibase-plugin: commandDefinition.shortDescription=Deploy any changes in the changelog file that have not been deployed
liquibase-plugin: commandDefinition.longDescription=null
liquibase-plugin: commandDefinition.arguments.keySet()=[]
max-norin commented 22 hours ago

In a future version of liquibase there will be a CommandFactory.resetCommandDefinitions() method. I think using it will solve the problem that arguments is empty.

https://github.com/liquibase/liquibase/blob/master/liquibase-standard/src/main/java/liquibase/command/CommandFactory.java#L246

    public void resetCommandDefinitions() {
        COMMAND_DEFINITIONS.clear();
    }
chschu commented 16 hours ago

I don't really understand what Liquibase does with its Scope. However, it seems a bit strange that CommandFactory. commandArgumentDefinitions is populated by static initializers (e. g. the .build() calls in UpdateToTagCommandStep), while the CommandFactory itself is bound to the Scope.