Three entities are involved here: Deployment, DeploymentStep, and DeploymentStatusLog. I\'ll start by pasting the relevan
I had this same problem, in my case it was because I was doing an entity remove & flush in a postRemove LifeCycle Event. From what I could grok in the UnitOfWork logic, you cannot call flush in that event. Doing so will flush any actions still pending to be flushed from the first call to flush, which will already have been removed by the flush call in the event. After figuring that out I was able to find this section of the Doctrine manual that confirmed my suspicion:
http://docs.doctrine-project.org/en/latest/reference/events.html#postupdate-postremove-postpersist
You are correct to assume that flushing each step individually is a bad approach, but if you don't make use of LifeCycle events then I'm not sure what could be causing your particular problem. I was able to debug the issue by error logging the object id variable ($oid) in the executeDeletions function of UnitOfWork.php. I noticed the same id was being deleted repeatedly, which once unset from $this->entityIdentifiers, will fail on subsequent deletes.
My solution was to simply catalog each ID in the postRemove event, and then actually remove the entities in a postFlush event, which is not a lifecycle event and therefore can make subsequent persist operations:
http://docs.doctrine-project.org/en/latest/reference/events.html#lifecycle-events
I'm sure you have since moved on, but in case anyone else runs into this problem...