Batch executeAsync does not start

Hi,
I am trying to migrate few process instances from one version to another using migration plan

In java code when I use execute() method then it is done immediately.
runtimeService.newMigration(migrationPlan) .processInstanceQuery(processQuery).execute();

But When I use executeAsync() method then I see the batch job waiting in the batches section but does not complete.

Can someone tell me what is the problem? I saw the question but did not find any solution Migration batch does not complete

I created a sample code which uses camunda 7.15.0 and can recreate the issue:-

This requires Postgres database. The database credentials need to be configured in application.yml file

mvn clean install
start the springboot application

http://localhost:1234/create-item - to start the camunda process which will just create an incident

http://localhost:1234/migrate/fromId/{fromProcessDefId}/toId/{toProcessDefId} - try to move the process instance from one process definition version to another

I’m using the excuteAsync() method which works fine for me, already with Camunda 7.6., an my code looks quite similar.

ProcessEngineService processEngineService = BpmPlatform.getProcessEngineService();
ProcessEngine processEngine = processEngineService.getDefaultProcessEngine();
MigrationPlan migrationPlan = processEngine.getRuntimeService().createMigrationPlan( processDefinitionBefore.getId(), processDefinitionAfter.getId() ).mapEqualActivities().build();
ProcessInstanceQuery processInstanceQuery = this.runtimeService.createProcessInstanceQuery().processDefinitionId( migrationPlan.getSourceProcessDefinitionId() );
List<ProcessInstance> instances = processInstanceQuery.list();
List<String> instanceIds = new ArrayList<>();
if ( !instances.isEmpty() ) {
    ArrayList<String> messages = new ArrayList<>();
    messages.add( String.format( Locale.GERMANY, "Starte Prozess-Instanz-Migration für %,d Instanzen.", Integer.valueOf( instances.size() ) ) );
    this.infoMessage( TASKS.BPT_DEPLOY_FILES, messages );

    messages.clear();
    messages.add( "Starte Prozess-Instanz-Migration für folgende ID's:" );
    for ( ProcessInstance processInstance : instances ) {
        messages.add( "- " + processInstance.getId() );
        instanceIds.add( processInstance.getId() );
    }
    this.debugMessage( TASKS.BPT_DEPLOY_FILES, messages );

    this.runtimeService.newMigration( migrationPlan ).processInstanceIds( instanceIds ).executeAsync();
}

Yes code looks similar… I think I am doing something wrong in dependencies or something I am not sure. I still could not find the issue in the repository link I shared GitHub - firstpostt/camunda-demo-migration

Found the problem

I was using unique constraint in postgres Database | docs.camunda.org

Then camunda batch is not working properly sometimes. I am not able to recreate the issue consistently but it has something to do with the unique constraint

I deleted the database and created it again from scratch. Then it works fine