Shireesh Anjal has uploaded a new change for review. Change subject: gluster: GlusterMultipleActionRunner ......................................................................
gluster: GlusterMultipleActionRunner Gluster commands always acquire a lock on the cluster. This means that if user selects multiple objects belonging to the same cluster and performs an action on them, all of them try to acquire a lock on the same cluster. The logic in MultipleActionsRunner is such that canDoActionOnly() is called for all actions first, before trying to execute them. This can result in a deadlock as the second action will get blocked trying to acquire lock on the same cluster, and executeAction() will never be invoked on first action because of this. This is seems like a gluster-specific scenario for now, hence introducing GlusterMultipleActionsRunner that extends from MultipleActionsRunner and alters the behavior as follows: - Releases the lock after invoking CanDoActionOnly - Re-acquires the lock invoking executing executeAction Change-Id: I0e3dc1fa0b21ab6e0fcaff518bf9696f6c9796ca Signed-off-by: Shireesh Anjal <san...@redhat.com> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GlusterMultipleActionsRunner.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java 2 files changed, 39 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/10812/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GlusterMultipleActionsRunner.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GlusterMultipleActionsRunner.java new file mode 100644 index 0000000..e632fa8 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GlusterMultipleActionsRunner.java @@ -0,0 +1,37 @@ +package org.ovirt.engine.core.bll; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +import org.ovirt.engine.core.common.action.VdcActionParametersBase; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VdcReturnValueBase; + +public class GlusterMultipleActionsRunner extends MultipleActionsRunner { + + public GlusterMultipleActionsRunner(VdcActionType actionType, + List<VdcActionParametersBase> parameters, + boolean isInternal) { + super(actionType, parameters, isInternal); + } + + @Override + protected void RunCanDoActionAsyncroniousely(final ArrayList<VdcReturnValueBase> returnValues, + final int currentCanDoActionId, final int totalSize, final CountDownLatch latch) { + try { + super.RunCanDoActionAsyncroniousely(returnValues, currentCanDoActionId, totalSize, latch); + } finally { + // free the lock so that canDoActionOnly() on next command doesn't block + getCommands().get(currentCanDoActionId).freeLock(); + } + } + + @Override + protected void executeValidatedCommands(CommandBase<?> command) { + // Since we had released the lock at the end of CanDoAction, + // it must be acquired back just before execution of the command + command.acquireLock(); + super.executeValidatedCommands(command); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java index 662bbea..9ccfe1e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java @@ -132,7 +132,7 @@ } } - private void RunCanDoActionAsyncroniousely( + protected void RunCanDoActionAsyncroniousely( final ArrayList<VdcReturnValueBase> returnValues, final int currentCanDoActionId, final int totalSize, final CountDownLatch latch) { ThreadPoolUtil.execute(new Runnable() { @@ -187,7 +187,7 @@ * @param command * The command to execute */ - final protected void executeValidatedCommands(CommandBase<?> command) { + protected void executeValidatedCommands(CommandBase<?> command) { if (command.getReturnValue().getCanDoAction()) { if (executionContext == null || executionContext.isMonitored()) { -- To view, visit http://gerrit.ovirt.org/10812 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0e3dc1fa0b21ab6e0fcaff518bf9696f6c9796ca Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shireesh Anjal <san...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches