mirror of https://github.com/apache/cloudstack.git
bug 10368: better fix for the db connection problem.
This commit is contained in:
parent
36ceb02abe
commit
22e28b4941
|
|
@ -489,7 +489,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
|
||||
}
|
||||
|
||||
@DB
|
||||
protected <T extends VMInstanceVO> Ternary<T, ReservationContext, ItWorkVO> changeToStartState(VirtualMachineGuru<T> vmGuru, T vm, User caller, Account account)
|
||||
throws ConcurrentOperationException {
|
||||
long vmId = vm.getId();
|
||||
|
|
@ -498,18 +497,18 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
int retry = _lockStateRetry;
|
||||
while (retry-- != 0) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
Ternary<T, ReservationContext, ItWorkVO> result = null;
|
||||
txn.start();
|
||||
try {
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
work = _workDao.persist(work);
|
||||
ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account);
|
||||
|
||||
if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) {
|
||||
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
work = _workDao.persist(work);
|
||||
ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
|
||||
}
|
||||
Ternary<T, ReservationContext, ItWorkVO> result = new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
result = new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
txn.commit();
|
||||
return result;
|
||||
}
|
||||
|
|
@ -517,6 +516,10 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to transition into Starting state due to " + e.getMessage());
|
||||
}
|
||||
} finally {
|
||||
if (result == null) {
|
||||
txn.rollback();
|
||||
}
|
||||
}
|
||||
|
||||
VMInstanceVO instance = _vmDao.findById(vmId);
|
||||
|
|
@ -1549,10 +1552,11 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
assert (agentState == State.Stopped || agentState == State.Running) : "If the states we send up is changed, this must be changed.";
|
||||
if (agentState == State.Running) {
|
||||
try {
|
||||
if(nativeHA)
|
||||
stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, hostId);
|
||||
else
|
||||
stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
if(nativeHA) {
|
||||
stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, hostId);
|
||||
} else {
|
||||
stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.warn(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue