Skip to content

Commit b6d8ced

Browse files
committed
there is no transaction context during the mgt server start, thus causing transaction.close will delete op_lock table if aquireinlocktable is called Reviewed-by: Anthony and Min
1 parent 8d3a9b7 commit b6d8ced

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import com.cloud.utils.db.DB;
6565
import com.cloud.utils.db.GlobalLock;
6666
import com.cloud.utils.db.SearchCriteria;
67+
import com.cloud.utils.db.TransactionLegacy;
6768

6869
@Component
6970
@Local(value = {SnapshotScheduler.class})
@@ -333,17 +334,21 @@ public Date scheduleNextSnapshotJob(final SnapshotPolicyVO policy) {
333334
spstSchedVO = new SnapshotScheduleVO(policy.getVolumeId(), policyId, nextSnapshotTimestamp);
334335
_snapshotScheduleDao.persist(spstSchedVO);
335336
} else {
337+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
338+
336339
try {
337340
spstSchedVO = _snapshotScheduleDao.acquireInLockTable(spstSchedVO.getId());
338341
spstSchedVO.setPolicyId(policyId);
339342
spstSchedVO.setScheduledTimestamp(nextSnapshotTimestamp);
340343
spstSchedVO.setAsyncJobId(null);
341344
spstSchedVO.setSnapshotId(null);
342345
_snapshotScheduleDao.update(spstSchedVO.getId(), spstSchedVO);
346+
txn.commit();
343347
} finally {
344348
if (spstSchedVO != null) {
345349
_snapshotScheduleDao.releaseFromLockTable(spstSchedVO.getId());
346350
}
351+
txn.close();
347352
}
348353
}
349354
return nextSnapshotTimestamp;

0 commit comments

Comments
 (0)