Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Lo
List<SnapshotDataStoreVO> listAllByVolumeAndDataStore(long volumeId, DataStoreRole role);

List<SnapshotDataStoreVO> listByState(ObjectInDataStoreStateMachine.State... states);

SnapshotDataStoreVO findDestroyedReferenceBySnapshot(long snapshotId, DataStoreRole role);
}
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ public List<SnapshotDataStoreVO> listByState(ObjectInDataStoreStateMachine.State
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,11 @@ public void cleanupSecondaryStorage(boolean recurring) {
}

_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());
Expand Down