- 
    Type:Bug Report 
- 
    Resolution: Fixed
- 
    Priority:L3 - Default 
- 
    Affects Version/s: None
- 
    Component/s: backend, continuous integration
- 
    None
- 
        Not defined
Context:
We sometimes see the Data upgrade test stage fail on branch builds due to an unexpected amount (exactly double) of event process instances during a republish test:
`com.camunda.optimize.test.upgrade.UpgradeDataIT.upgradeWithDataAndPerformRegressionTest`:
Failures (1):
  JUnit Jupiter:PostMigrationTest:republishAllEventBasedProcessesAndEnsureTheyArePublishedAndHaveInstanceData()
    MethodSource [className = 'com.camunda.optimize.test.upgrade.PostMigrationTest', methodName = 'republishAllEventBasedProcessesAndEnsureTheyArePublishedAndHaveInstanceData', methodParameterTypes = '']
    => org.opentest4j.AssertionFailedError: 
expected: {"46ade747-84f2-4b40-85a2-fbdbef73543e"=3L, "7b917036-cd64-4e39-9464-7d4457adf51b"=10L}
but was : {"46ade747-84f2-4b40-85a2-fbdbef73543e"=6L, "7b917036-cd64-4e39-9464-7d4457adf51b"=10L}
	at com.camunda.optimize.test.upgrade.UpgradeDataIT.upgradeWithDataAndPerformRegressionTest(UpgradeDataIT.groovy:53)
AT:
- identify the cause and either adjust the test or the publish logic to avoid the potential race-condition
Hint:
This may be caused by a race condition between the actual process republish call as the new publish state is created before the old one is deleted and the `EventBasedProcessesInstanceImportScheduler` may run just in between that time window when both exist at the same time.