Arik Hadas has uploaded a new change for review. Change subject: core: remove read lock of template while creating VM from it ......................................................................
core: remove read lock of template while creating VM from it This patch is using the new mechanism that let us run commands without release their lock at the end of the sync execution part, in order to remove the unnecessary read lock of template while we create VM that is based on this template. so with this patch, it is now possible to create multiple VMs that are based on the same template with preallocated disks which wasn't possible before. The AddVmFromTemplate command was modified in such a way that it won't lock the template in the DB. instead, we take a shared-lock for the whole execution process (sync + async, until the command is finished). The call to "freeLock" in AddVmCommand#executeVmCommand was also removed, so that the shared lock would not be released. it seems that this call was not required for the AddVmCommand (because it is set to release the lock at the end of this method anyway) and not for the commands that inherit it. Change-Id: If1b74347110c468b90e75b4dc6470595576f94f4 Bug-Url: https://bugzilla.redhat.com/815642 Signed-off-by: Arik Hadas <aha...@redhat.com> --- 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/AddVmFromTemplateCommand.java 2 files changed, 3 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/12407/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 8b90c6a..e65b734 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 @@ -486,7 +486,6 @@ return null; } }); - freeLock(); addVmPermission(); if (addVmImages()) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromTemplateCommand.java index acda81f..4897d14 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromTemplateCommand.java @@ -18,7 +18,7 @@ import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; -@LockIdNameAttribute +@LockIdNameAttribute(isReleaseAtEndOfExecute = false) public class AddVmFromTemplateCommand<T extends AddVmFromTemplateParameters> extends AddVmCommand<T> { public AddVmFromTemplateCommand(T parameters) { @@ -36,9 +36,9 @@ } @Override - protected Map<String, Pair<String, String>> getExclusiveLocks() { + protected Map<String, Pair<String, String>> getSharedLocks() { Map<String, Pair<String, String>> locks = new HashMap<String, Pair<String, String>>(); - Map<String, Pair<String, String>> parentLocks = super.getExclusiveLocks(); + Map<String, Pair<String, String>> parentLocks = super.getSharedLocks(); if (parentLocks != null) { locks.putAll(parentLocks); } @@ -48,7 +48,6 @@ @Override protected void executeVmCommand() { - VmTemplateHandler.lockVmTemplateInTransaction(getVmTemplateId(), getCompensationContext()); super.executeVmCommand(); getParameters().OriginalTemplate = getVm().getVmtGuid(); getVm().setVmtGuid(VmTemplateHandler.BlankVmTemplateId); @@ -127,17 +126,5 @@ actualSize += disk.getActualSize(); } return (int) actualSize; - } - - @Override - protected void endSuccessfully() { - super.endSuccessfully(); - VmTemplateHandler.UnLockVmTemplate(getParameters().OriginalTemplate); - } - - @Override - protected void endWithFailure() { - super.endWithFailure(); - VmTemplateHandler.UnLockVmTemplate(getParameters().OriginalTemplate); } } -- To view, visit http://gerrit.ovirt.org/12407 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If1b74347110c468b90e75b4dc6470595576f94f4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches