mirror of https://github.com/apache/cloudstack.git
SUPPORT-69: Async Job Database Connection Timeouts
This commit is contained in:
parent
7385441807
commit
5f5c928c0f
|
|
@ -52,6 +52,7 @@ import com.cloud.storage.dao.VMTemplateDao;
|
|||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
||||
|
|
@ -184,6 +185,8 @@ public class TemplateObject implements TemplateInfo {
|
|||
@Override
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
|
||||
try {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.checkConnection();
|
||||
if (getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
if (answer instanceof CopyCmdAnswer) {
|
||||
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.cloud.storage.dao.SnapshotDao;
|
|||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.db.QueryBuilder;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
|
@ -288,6 +289,8 @@ public class SnapshotObject implements SnapshotInfo {
|
|||
@Override
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
|
||||
try {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.checkConnection();
|
||||
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(getDataStore().getRole(), getDataStore().getId(), getId());
|
||||
if (answer instanceof CreateObjectAnswer) {
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CreateObjectAnswer)answer).getData();
|
||||
|
|
|
|||
|
|
@ -177,6 +177,16 @@ public class TransactionLegacy implements Closeable {
|
|||
return txn;
|
||||
}
|
||||
|
||||
public void checkConnection() {
|
||||
try {
|
||||
if (_conn != null && !_conn.isValid(3)) {
|
||||
_conn = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
_conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected StackElement peekInStack(Object obj) {
|
||||
final Iterator<StackElement> it = _stack.iterator();
|
||||
while (it.hasNext()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue