Arik Hadas has uploaded a new change for review. Change subject: core: lock vm name for the whole vm import operation ......................................................................
core: lock vm name for the whole vm import operation The name of the VM is being locked when importing VM, since we want to prevent creation of another vm with the same name in parallel. the lock for the VM name was taken until we were adding the VM to the DB, since once it is in the DB, every command that creates VM can find whether VM with such name already exists or not by checking the DB, so the lock is no longer required. The granularity of the locks scope definition is per class, which means that either all the acquired locks are released at the end of the execute method or all of them remains until the whole execution of the command ends. Since we need to add locks which remain for the whole execution in ImportVmCommand, we need the VM name lock to remain for the whole execution as well. This patch changes the scope of the VM name lock that is taken as part of the import vm operation to be for the whole execution. The message which is attached to the log is also changed to reflect the error better (so from the user's perspective, it makes no difference whether other commands fail because of the lock in memory or due to detection that there is already another VM with the same name in the DB). Change-Id: I8e04a40f46389da77b67b997931377d8e1193935 Bug-Url: https://bugzilla.redhat.com/733917 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java 1 file changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/16954/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java index 2743c40..057ca9c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java @@ -92,7 +92,7 @@ @DisableInPrepareMode @NonTransactiveCommandAttribute(forceCompensation = true) -@LockIdNameAttribute +@LockIdNameAttribute(isReleaseAtEndOfExecute = false) public class ImportVmCommand extends MoveOrCopyTemplateCommand<ImportVmParameters> implements QuotaStorageDependent, TaskHandlerCommand<ImportVmParameters> { private static final Log log = LogFactory.getLog(ImportVmCommand.class); @@ -124,7 +124,7 @@ protected Map<String, Pair<String, String>> getExclusiveLocks() { if (!StringUtils.isBlank(getParameters().getVm().getName())) { return Collections.singletonMap(getParameters().getVm().getName(), - LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM_NAME, VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM_NAME, VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED)); } return null; } @@ -605,7 +605,6 @@ return null; } }); - freeLock(); } private void processImages() { -- To view, visit http://gerrit.ovirt.org/16954 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e04a40f46389da77b67b997931377d8e1193935 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
