Skip to content

Commit 4c15cfc

Browse files
committed
Merge release branch 4.9 to master
* 4.9: CLOUDSTACK-9460: For long running transactions, if the connection is timed out by the mysql server then refresh it
2 parents ad0c25f + 22d0746 commit 4c15cfc

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

framework/db/src/com/cloud/utils/db/TransactionLegacy.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,24 @@ public static TransactionLegacy open(final String name, final short databaseId,
168168
isNew = true;
169169
}
170170
}
171-
171+
txn.checkConnection();
172172
txn.takeOver(name, false);
173173
if (isNew) {
174174
s_mbean.addTransaction(txn);
175175
}
176176
return txn;
177177
}
178178

179+
public void checkConnection() {
180+
try {
181+
if (_conn != null && !_conn.isValid(3)) {
182+
_conn = null;
183+
}
184+
} catch (SQLException e) {
185+
_conn = null;
186+
}
187+
}
188+
179189
protected StackElement peekInStack(Object obj) {
180190
final Iterator<StackElement> it = _stack.iterator();
181191
while (it.hasNext()) {

0 commit comments

Comments
 (0)