Repository: cloudstack Updated Branches: refs/heads/4.5 2777caddb -> 7eac6310b
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 <[email protected]> This closes #551 (cherry picked from commit 5d9f851deb1a12e4a07297353ea715f9cf13e677) Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7eac6310 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7eac6310 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7eac6310 Branch: refs/heads/4.5 Commit: 7eac6310bc1f67e8c61980d43cd31586032503ee Parents: 2777cad Author: Koushik Das <[email protected]> Authored: Wed Jul 1 23:17:46 2015 +0530 Committer: Rohit Yadav <[email protected]> Committed: Fri Jul 3 15:28:22 2015 +0530 ---------------------------------------------------------------------- .../api/query/dao/ResourceTagJoinDaoImpl.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7eac6310/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java index a496753..3ec10dd 100644 --- a/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java @@ -149,20 +149,24 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo public ResourceTagJoinVO searchById(Long id) { SearchCriteria<ResourceTagJoinVO> sc = tagIdSearch.create(); sc.setParameters("id", id); - List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false); - assert vms != null && vms.size() == 1 : "No tag found for tag id " + id; - return vms.get(0); + List<ResourceTagJoinVO> tags = searchIncludingRemoved(sc, null, null, false); + if (tags != null && tags.size() > 0) { + return tags.get(0); + } else { + return null; + } } @Override public ResourceTagJoinVO newResourceTagView(ResourceTag vr) { - SearchCriteria<ResourceTagJoinVO> sc = tagIdSearch.create(); sc.setParameters("id", vr.getId()); - List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false); - assert vms != null && vms.size() == 1 : "No tag found for tag id " + vr.getId(); - return vms.get(0); - + List<ResourceTagJoinVO> tags = searchIncludingRemoved(sc, null, null, false); + if (tags != null && tags.size() > 0) { + return tags.get(0); + } else { + return null; + } } }
