Roy Golan has uploaded a new change for review.

Change subject: core: call Failed to runVms on different thread
......................................................................

core: call Failed to runVms on different thread

on a busy system we can hit a deadlock in a situation where 2 Vdsmanager
are failing to run a VM and are notifying each other a FailedToRunVm VDS
command.

to avoid each one blocking on other's lock the specific action of
notifying other hosts is performed in a new thread to try and conclude
the thread run more quickly and release the lock.

Change-Id: If4d760aa270a3f07b13d1579d7b02c838cb4dd15
Bug-Url: https://bugzilla.redhat.com/878890
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
1 file changed, 22 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/10002/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index c320d6f..9a5a3fe 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -284,12 +284,7 @@
         log();
         ExecutionHandler.setAsyncJob(getExecutionContext(), false);
         ExecutionHandler.endJob(getExecutionContext(), true);
-        for (Guid vdsId : getRunVdssList()) {
-            if (!getCurrentVdsId().equals(vdsId)) {
-                Backend.getInstance().getResourceManager()
-                        .RunVdsCommand(VDSCommandType.FailedToRunVm, new 
FailedToRunVmVDSCommandParameters(vdsId));
-            }
-        }
+        notifyHostsVmFailed();
 
         if (getVm().getLastVdsRunOn() == null || 
!getVm().getLastVdsRunOn().equals(getCurrentVdsId())) {
             getVm().setLastVdsRunOn(getCurrentVdsId());
@@ -310,6 +305,27 @@
         }
     }
 
+    /**
+     * notify other hosts on a failed attempt to run a Vm in a non blocking 
matter
+     * to avoid deadlock where other host's VdsManagers lock is taken and is 
awaiting the current vds lock.
+     */
+    private void notifyHostsVmFailed() {
+        if (!getRunVdssList().isEmpty()) {
+            ThreadPoolUtil.execute(new Runnable() {
+
+                public void run() {
+                    for (Guid vdsId : getRunVdssList()) {
+                        if (!getCurrentVdsId().equals(vdsId)) {
+                            Backend.getInstance().getResourceManager()
+                                    
.RunVdsCommand(VDSCommandType.FailedToRunVm, new 
FailedToRunVmVDSCommandParameters(vdsId));
+                        }
+                    }
+                }
+
+            });
+        }
+    }
+
     @Override
     public void reportCompleted() {
         ExecutionContext executionContext = getExecutionContext();


--
To view, visit http://gerrit.ovirt.org/10002
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4d760aa270a3f07b13d1579d7b02c838cb4dd15
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to