mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
bug 6278: fix the race condition that take snapshot/and delete snapshot at the same time
status 6278: resolved fixed
This commit is contained in:
parent
dcb40b5b15
commit
b24cf4715b
@ -1445,7 +1445,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
StoragePool secondaryStoragePool = getNfsSPbyURI(_conn, new URI(secondaryStoragePoolURL));
|
||||
String ssPmountPath = _mountPoint + File.separator + secondaryStoragePool.getUUIDString();
|
||||
snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
|
||||
Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
|
||||
Script command = new Script(_manageSnapshotPath, 1800000, s_logger);
|
||||
command.add("-b", snapshotPath);
|
||||
command.add("-n", snapshotName);
|
||||
command.add("-p", snapshotDestPath);
|
||||
|
||||
@ -107,6 +107,7 @@ import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@ -323,7 +324,18 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public SnapshotVO createSnapshotImpl(Long volumeId, Long policyId, Long snapshotId, Long startEventId) throws ResourceAllocationException {
|
||||
public SnapshotVO createSnapshotImpl(Long volumeId, Long policyId, Long snapshotId, Long startEventId) throws ResourceAllocationException {
|
||||
VolumeVO v = _volsDao.findById(volumeId);
|
||||
if ( v != null && _volsDao.getHypervisorType(v.getId()).equals(HypervisorType.KVM)) {
|
||||
/*KVM needs to lock on the vm of volume, because it takes snapshot on behalf of vm, not volume*/
|
||||
UserVmVO uservm = _vmDao.findById(v.getInstanceId());
|
||||
if (uservm != null) {
|
||||
UserVmVO vm = _vmDao.acquireInLockTable(uservm.getId(), 10);
|
||||
if (vm == null) {
|
||||
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is being used, try it later ");
|
||||
}
|
||||
}
|
||||
}
|
||||
VolumeVO volume = _volsDao.acquireInLockTable(volumeId, 10);
|
||||
if( volume == null ) {
|
||||
volume = _volsDao.findById(volumeId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user