mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix snapshots garbage collection (#4188)
* Cleanup orphan entries from snapshot store ref for primary storage * Add debug message
This commit is contained in:
parent
affd010418
commit
f843c537f0
@ -71,4 +71,6 @@ StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Even
|
||||
List<SnapshotDataStoreVO> listAllByVolumeAndDataStore(long volumeId, DataStoreRole role);
|
||||
|
||||
List<SnapshotDataStoreVO> listByState(ObjectInDataStoreStateMachine.State... states);
|
||||
|
||||
SnapshotDataStoreVO findDestroyedReferenceBySnapshot(long snapshotId, DataStoreRole role);
|
||||
}
|
||||
|
||||
@ -461,6 +461,15 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SnapshotDataStoreVO findDestroyedReferenceBySnapshot(long snapshotId, DataStoreRole role) {
|
||||
SearchCriteria<SnapshotDataStoreVO> sc = snapshotSearch.create();
|
||||
sc.setParameters("snapshot_id", snapshotId);
|
||||
sc.setParameters("store_role", role);
|
||||
sc.setParameters("state", State.Destroyed);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
private boolean isSnapshotChainingRequired(long volumeId) {
|
||||
|
||||
hypervisorsSupportingSnapshotsChaining.add(Hypervisor.HypervisorType.XenServer);
|
||||
|
||||
@ -1393,8 +1393,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
}
|
||||
|
||||
_snapshotDao.remove(destroyedSnapshotStoreVO.getSnapshotId());
|
||||
SnapshotDataStoreVO snapshotOnPrimary = _snapshotStoreDao.findBySnapshot(destroyedSnapshotStoreVO.getSnapshotId(), DataStoreRole.Primary);
|
||||
SnapshotDataStoreVO snapshotOnPrimary = _snapshotStoreDao.findDestroyedReferenceBySnapshot(destroyedSnapshotStoreVO.getSnapshotId(), DataStoreRole.Primary);
|
||||
if (snapshotOnPrimary != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Deleting snapshot on primary store reference DB entry: " + snapshotOnPrimary);
|
||||
}
|
||||
_snapshotStoreDao.remove(snapshotOnPrimary.getId());
|
||||
}
|
||||
_snapshotStoreDao.remove(destroyedSnapshotStoreVO.getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user