From 0d6f69b536dc04e154678e5198cfd9c71097656e Mon Sep 17 00:00:00 2001 From: Min Chen Date: Thu, 23 Oct 2014 14:08:49 -0700 Subject: [PATCH] CLOUDSTACK-7778: Start VM checkWorkItem loop should also check VM DB state before going into idle waiting to exit faster. --- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 0eafe137445..ec4aa1d1b9c 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -629,6 +629,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac return true; } + // also check DB to get latest VM state to detect vm update from concurrent process before idle waiting to get an early exit + VMInstanceVO instance = _vmDao.findById(vm.getId()); + if (instance != null && instance.getState() == State.Running) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("VM is already started in DB: " + vm); + } + return true; + } + if (vo.getSecondsTaskIsInactive() > VmOpCancelInterval.value()) { s_logger.warn("The task item for vm " + vm + " has been inactive for " + vo.getSecondsTaskIsInactive()); return false;