When using vCloud API to reconfigure VMs of a vapp in multiple threads, hibernate of VCD reports this error:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.vmware.vcloud.common.model.net.LogicalNetworkModel#831832908] at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635) at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027) at com.vmware.vcloud.common.persist.Conversation.flush(Conversation.java:497) at com.vmware.vcloud.common.persist.Conversation.commitTransaction(Conversation.java:191) at com.vmware.vcloud.net.dao.impl.HibernateLogicalNetworkDao.updateServiceConfiguration(HibernateLogicalNetworkDao.java:380) at com.vmware.vcloud.net.impl.DefaultLogicalNetworkManager.saveUpdatedServiceConfiguration(DefaultLogicalNetworkManager.java:1262) at com.vmware.vcloud.net.impl.DefaultLogicalNetworkManager.notifyNicsAddedOrRemoved(DefaultLogicalNetworkManager.java:1891) at com.vmware.ssdc.backend.services.impl.VmManagerImpl.updateVm(VmManagerImpl.java:1139)
This is very annoying because we need to make all changes one after an other... it takes time!
do we mean hibernation of vcd appliance?
I mean when VCD try to persist the virtual machine (and/or virtual appliance). This is what logs say.
Given that there are relationships between VMs, the vApp they are owned by, and any vApp networks, you probably don't want to use multiple threads to try and update them all concurrently because, as you've found, you'll run into optimistic concurrency control problems.
You're probably safe updating VMs from different vApps (where there is little to no overlap / relationships) concurrently, but beware whenever there are shared resources such as a network.
Why don't you reduce the critic section by saving only modified datas?
I mean, I would like to be able to update VirtualHardware section and GuestCustomization section at the same time, there is no common datas in it. Ok for the NetworkConnection which share network informations with other VMs.
In fact DAO should update modified data, not the whole VM.
Regards.