Arik Hadas has uploaded a new change for review. Change subject: core: extract memory images removal on remove vm out of transaction ......................................................................
core: extract memory images removal on remove vm out of transaction On remove vm command, the data we remove from the DB is being removed inside a transaction. The memory images removal, which is a vdsm operation, is also made inside this trasaction and this is wrong - vdsm operations should be executed out of transactions. So this patch extract the call to vdsm for removing the memory images which is taking place as part of remove vm command to be executed out of transaction. Change-Id: I908f8e9fe4e276063aa88357c3cbfe9ae56be501 Bug-Url: https://bugzilla.redhat.com/985410 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java 3 files changed, 36 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/17308/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 35ab077..8f3b36a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -760,6 +760,9 @@ protected void removeVmRelatedEntitiesFromDb() { removeVmUsers(); removeVmNetwork(); + // Note that currently newly added vm never have memory state + // In case it will be changed (clone vm from snapshot will clone the memory state), + // we'll need to remove the memory state images here as well. removeVmSnapshots(); removeVmStatic(); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java index 0c4eeb9..1a8866e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java @@ -9,11 +9,13 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.job.ExecutionHandler; +import org.ovirt.engine.core.bll.memory.MemoryImageRemoverOnDataDomain; import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageDependent; import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator; import org.ovirt.engine.core.bll.storage.StoragePoolValidator; +import org.ovirt.engine.core.bll.tasks.TaskHandlerCommand; import org.ovirt.engine.core.bll.utils.PermissionSubject; import org.ovirt.engine.core.bll.validator.DiskImagesValidator; import org.ovirt.engine.core.bll.validator.MultipleStorageDomainsValidator; @@ -42,7 +44,9 @@ @DisableInPrepareMode @LockIdNameAttribute @NonTransactiveCommandAttribute(forceCompensation = true) -public class RemoveVmCommand<T extends RemoveVmParameters> extends VmCommand<T> implements QuotaStorageDependent{ +public class RemoveVmCommand<T extends RemoveVmParameters> extends VmCommand<T> implements QuotaStorageDependent, TaskHandlerCommand<RemoveVmParameters> { + + private Set<String> memoryStates; /** * Constructor for command creation when compensation is applied on startup @@ -103,6 +107,8 @@ return false; } } + + new MemoryImageRemoverOnDataDomain(getVm(), this).remove(memoryStates); return true; } @@ -253,7 +259,7 @@ removeLunDisks(); removeVmUsers(); removeVmNetwork(); - removeVmSnapshots(); + memoryStates = removeVmSnapshots(); removeVmStatic(); } @@ -305,4 +311,26 @@ } return list; } + + //////////////////////////// + //// TaskHandleCommand //// + //////////////////////////// + + @Override + public void preventRollback() { } + + @Override + public Guid persistAsyncTaskPlaceHolder() { + return super.persistAsyncTaskPlaceHolder(getActionType()); + } + + @Override + public Guid persistAsyncTaskPlaceHolder(String taskKey) { + return super.persistAsyncTaskPlaceHolder(getActionType(), taskKey); + } + + @Override + public VdcActionType getActionType() { + return super.getActionType(); + } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java index a59430f..5256f0a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Set; import org.ovirt.engine.core.bll.network.MacPoolManager; import org.ovirt.engine.core.bll.snapshots.SnapshotsManager; @@ -173,14 +174,8 @@ } } - protected void removeVmSnapshots() { - Collection<String> memoriesOfRemovedSnapshots = - new SnapshotsManager().removeSnapshots(getVmId()); - for (String memoryVolumes : memoriesOfRemovedSnapshots) { - if (shouldRemoveMemorySnapshotVolumes(memoryVolumes)) { - removeMemoryVolumes(memoryVolumes, getActionType(), false); - } - } + protected Set<String> removeVmSnapshots() { + return new SnapshotsManager().removeSnapshots(getVmId()); } /** -- To view, visit http://gerrit.ovirt.org/17308 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I908f8e9fe4e276063aa88357c3cbfe9ae56be501 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
