mirror of https://github.com/apache/cloudstack.git
bug 10512: lock on snapshot entry instead of volume entry
status 10512: resolved fixed
This commit is contained in:
parent
ed614c4f52
commit
b6eafd7102
|
|
@ -627,8 +627,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
Long templateId = template.getId();
|
||||
Long tmpltAccountId = template.getAccountId();
|
||||
if (!_volsDao.lockInLockTable(volumeId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("failed to upgrade snapshot " + snapshotId + " due to volume:" + volumeId + " is being used, try it later ");
|
||||
if (!_snapshotDao.lockInLockTable(snapshotId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("failed to upgrade snapshot " + snapshotId + " due to this snapshot is being used, try it later ");
|
||||
}
|
||||
UpgradeSnapshotCommand cmd = new UpgradeSnapshotCommand(null, secondaryStoragePoolUrl, dcId, accountId, volumeId, templateId, tmpltAccountId, null, snapshot.getBackupSnapshotId(),
|
||||
snapshot.getName(), "2.1");
|
||||
|
|
@ -637,7 +637,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
answer = sendToPool(pool, cmd);
|
||||
} catch (StorageUnavailableException e) {
|
||||
} finally {
|
||||
_volsDao.unlockFromLockTable(volumeId.toString());
|
||||
_snapshotDao.unlockFromLockTable(snapshotId.toString());
|
||||
}
|
||||
if ((answer != null) && answer.getResult()) {
|
||||
_snapshotDao.updateSnapshotVersion(volumeId, "2.1", "2.2");
|
||||
|
|
@ -655,7 +655,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
String basicErrMsg = "Failed to create volume from " + snapshot.getName();
|
||||
CreateVolumeFromSnapshotAnswer answer;
|
||||
if (!_snapshotDao.lockInLockTable(snapshotId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("failed to create volume from " + snapshotId + " due to original volume:" + volumeId + " is being used, try it later ");
|
||||
throw new CloudRuntimeException("failed to create volume from " + snapshotId + " due to this snapshot is being used, try it later ");
|
||||
}
|
||||
try {
|
||||
answer = (CreateVolumeFromSnapshotAnswer) sendToPool(pool, createVolumeFromSnapshotCommand);
|
||||
|
|
|
|||
|
|
@ -1545,14 +1545,24 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
// This can be sent to a KVM host too.
|
||||
CreatePrivateTemplateAnswer answer = null;
|
||||
if (!_volsDao.lockInLockTable(volumeId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("Creating template failed due to volume:" + volumeId + " is being used, try it later ");
|
||||
if (snapshotId != null) {
|
||||
if (!_snapshotDao.lockInLockTable(snapshotId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("Creating template from snapshot failed due to snapshot:" + snapshotId + " is being used, try it later ");
|
||||
}
|
||||
} else {
|
||||
if (!_volsDao.lockInLockTable(volumeId.toString(), 10)) {
|
||||
throw new CloudRuntimeException("Creating template from volume failed due to volume:" + volumeId + " is being used, try it later ");
|
||||
}
|
||||
}
|
||||
try {
|
||||
answer = (CreatePrivateTemplateAnswer) _storageMgr.sendToPool(pool, cmd);
|
||||
} catch (StorageUnavailableException e) {
|
||||
} finally {
|
||||
_volsDao.unlockFromLockTable(volumeId.toString());
|
||||
if (snapshotId != null) {
|
||||
_snapshotDao.unlockFromLockTable(snapshotId.toString());
|
||||
} else {
|
||||
_volsDao.unlockFromLockTable(volumeId.toString());
|
||||
}
|
||||
}
|
||||
if ((answer != null) && answer.getResult()) {
|
||||
privateTemplate = _templateDao.findById(templateId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue