Skip to content

Commit 8eaa53f

Browse files
committed
fix transaction rollback in security group listener, which cause state machine update failed
1 parent 5d3052c commit 8eaa53f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎server/src/com/cloud/network/security/SecurityGroupManagerImpl.java‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,15 @@ public void scheduleRulesetUpdateToHosts(Set<Long> affectedVms, boolean updateSe
325325
}
326326

327327
for (Long vmId: affectedVms) {
328-
Transaction txn = Transaction.currentTxn();
329-
txn.start();
328+
330329
VmRulesetLogVO log = null;
331330
SecurityGroupWorkVO work = null;
332331
UserVm vm = null;
332+
Transaction txn = null;
333333
try {
334+
txn = Transaction.currentTxn();
335+
txn.start();
336+
334337
vm = _userVMDao.acquireInLockTable(vmId);
335338
if (vm == null) {
336339
s_logger.warn("Failed to acquire lock on vm id " + vmId);
@@ -359,8 +362,10 @@ public void scheduleRulesetUpdateToHosts(Set<Long> affectedVms, boolean updateSe
359362
if (vm != null) {
360363
_userVMDao.releaseFromLockTable(vmId);
361364
}
365+
366+
if (txn != null)
367+
txn.commit();
362368
}
363-
txn.commit();
364369

365370
_executorPool.schedule(new WorkerThread(), delayMs, TimeUnit.MILLISECONDS);
366371

0 commit comments

Comments
 (0)