Skip to content

Commit 5d9f851

Browse files
koushik-dasyadvr
authored andcommitted
CLOUDSTACK-8603: Random list VM failures at scale (more than 1000 VMs) when VM has resource tags There is no 'removed' field on the resource_tags table. So 'id' based search may return a record or null in case record is deleted. Added a check for null or empty in search resource tags based on 'id'.
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes apache#551
1 parent 3a19a89 commit 5d9f851

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,24 @@ public List<ResourceTagJoinVO> searchByIds(Long... tagIds) {
149149
public ResourceTagJoinVO searchById(Long id) {
150150
SearchCriteria<ResourceTagJoinVO> sc = tagIdSearch.create();
151151
sc.setParameters("id", id);
152-
List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
153-
assert vms != null && vms.size() == 1 : "No tag found for tag id " + id;
154-
return vms.get(0);
152+
List<ResourceTagJoinVO> tags = searchIncludingRemoved(sc, null, null, false);
153+
if (tags != null && tags.size() > 0) {
154+
return tags.get(0);
155+
} else {
156+
return null;
157+
}
155158
}
156159

157160
@Override
158161
public ResourceTagJoinVO newResourceTagView(ResourceTag vr) {
159-
160162
SearchCriteria<ResourceTagJoinVO> sc = tagIdSearch.create();
161163
sc.setParameters("id", vr.getId());
162-
List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
163-
assert vms != null && vms.size() == 1 : "No tag found for tag id " + vr.getId();
164-
return vms.get(0);
165-
164+
List<ResourceTagJoinVO> tags = searchIncludingRemoved(sc, null, null, false);
165+
if (tags != null && tags.size() > 0) {
166+
return tags.get(0);
167+
} else {
168+
return null;
169+
}
166170
}
167171

168172
}

0 commit comments

Comments
 (0)