CLOUDSTACK-9460: For long running transactions, if the connection is

timed out by the mysql server then refresh it
This commit is contained in:
Abhinandan Prateek 2016-08-17 16:15:15 +05:30
parent 9eb8b2e90b
commit a813baed49
1 changed files with 11 additions and 1 deletions

View File

@ -168,7 +168,7 @@ public class TransactionLegacy implements Closeable {
isNew = true; isNew = true;
} }
} }
txn.checkConnection();
txn.takeOver(name, false); txn.takeOver(name, false);
if (isNew) { if (isNew) {
s_mbean.addTransaction(txn); s_mbean.addTransaction(txn);
@ -176,6 +176,16 @@ public class TransactionLegacy implements Closeable {
return txn; return txn;
} }
public void checkConnection() {
try {
if (_conn != null && !_conn.isValid(3)) {
_conn = null;
}
} catch (SQLException e) {
_conn = null;
}
}
protected StackElement peekInStack(Object obj) { protected StackElement peekInStack(Object obj) {
final Iterator<StackElement> it = _stack.iterator(); final Iterator<StackElement> it = _stack.iterator();
while (it.hasNext()) { while (it.hasNext()) {