mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
bug 10368: Print out the hash code of the db connection instead of the toString(). Changed the transaction in changeToStart() method to be of a shorter interval so it won't cause so many db connection exceptions
This commit is contained in:
parent
0ef23b8661
commit
e4f42d0e52
@ -500,56 +500,54 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
try {
|
||||
if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) {
|
||||
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);
|
||||
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());
|
||||
}
|
||||
return new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to transition into Starting state due to " + e.getMessage());
|
||||
s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
|
||||
}
|
||||
return new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
}
|
||||
|
||||
} catch (NoTransitionException e) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Determining why we're unable to update the state to Starting for " + vm);
|
||||
}
|
||||
|
||||
VMInstanceVO instance = _vmDao.findById(vmId);
|
||||
if (instance == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
|
||||
}
|
||||
|
||||
State state = instance.getState();
|
||||
if (state == State.Running) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.isTransitional()) {
|
||||
if (!checkWorkItems(vm, state)) {
|
||||
throw new ConcurrentOperationException("There are concurrent operations on the VM " + vm);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
return null;
|
||||
s_logger.debug("Unable to transition into Starting state due to " + e.getMessage());
|
||||
}
|
||||
} finally {
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
VMInstanceVO instance = _vmDao.findById(vmId);
|
||||
if (instance == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Determining why we're unable to update the state to Starting for " + instance + ". Retry=" + retry);
|
||||
}
|
||||
|
||||
State state = instance.getState();
|
||||
if (state == State.Running) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.isTransitional()) {
|
||||
if (!checkWorkItems(vm, state)) {
|
||||
throw new ConcurrentOperationException("There are concurrent operations on " + vm);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ConcurrentOperationException("Unable to change the state of " + vm);
|
||||
|
||||
@ -175,7 +175,7 @@ public class Transaction {
|
||||
public static Connection getStandaloneConnectionWithException() throws SQLException {
|
||||
Connection conn = s_ds.getConnection();
|
||||
if (s_connLogger.isTraceEnabled()) {
|
||||
s_logger.trace("Retrieving a standalone connection: " + conn);
|
||||
s_logger.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn));
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
@ -184,7 +184,7 @@ public class Transaction {
|
||||
try {
|
||||
Connection conn = s_ds.getConnection();
|
||||
if (s_connLogger.isTraceEnabled()) {
|
||||
s_logger.trace("Retrieving a standalone connection: " + conn);
|
||||
s_logger.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn));
|
||||
}
|
||||
return conn;
|
||||
} catch (SQLException e) {
|
||||
@ -197,7 +197,7 @@ public class Transaction {
|
||||
try {
|
||||
Connection conn = s_usageDS.getConnection();
|
||||
if (s_connLogger.isTraceEnabled()) {
|
||||
s_logger.trace("Retrieving a standalone connection for usage: " + conn);
|
||||
s_logger.trace("Retrieving a standalone connection for usage: dbconn" + System.identityHashCode(conn));
|
||||
}
|
||||
return conn;
|
||||
} catch (SQLException e) {
|
||||
@ -496,7 +496,7 @@ public class Transaction {
|
||||
_conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
|
||||
_stack.push(new StackElement(CREATE_CONN, null));
|
||||
if (s_connLogger.isTraceEnabled()) {
|
||||
s_connLogger.trace("Creating a DB connection with " + (_txn ? " txn: " : " no txn: ") + " for " + _dbId + ": " + _conn + buildName());
|
||||
s_connLogger.trace("Creating a DB connection with " + (_txn ? " txn: " : " no txn: ") + " for " + _dbId + ": dbconn" + System.identityHashCode(_conn) + ". Stack: " + buildName());
|
||||
}
|
||||
} else {
|
||||
s_logger.trace("conn: Using existing DB connection");
|
||||
@ -665,7 +665,7 @@ public class Transaction {
|
||||
|
||||
try {
|
||||
if (s_connLogger.isTraceEnabled()) {
|
||||
s_logger.trace("Closing DB connection: " + _conn);
|
||||
s_logger.trace("Closing DB connection: dbconn" + System.identityHashCode(_conn));
|
||||
}
|
||||
if(this._dbId != CONNECTED_DB) {
|
||||
_conn.close();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user