mirror of https://github.com/apache/cloudstack.git
Merge pull request #477 from shapeblue/list_events_sql_error
List Events returns intermittent SQL exception.
This commit is contained in:
commit
2755e338d8
|
|
@ -739,8 +739,14 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
Integer count = eventIdPage.second();
|
||||
Long[] idArray = eventIdPage.first().toArray(new Long[0]);
|
||||
|
||||
if (count == 0) {
|
||||
return new Pair<>(new ArrayList<>(), count);
|
||||
/**
|
||||
* Need to check array empty, because {@link com.cloud.utils.db.GenericDaoBase#searchAndCount(SearchCriteria, Filter, boolean)}
|
||||
* makes two calls: first to get objects and second to get count.
|
||||
* List events has start date filter, there is highly possible cause where no objects loaded
|
||||
* and next millisecond new event added and finally we ended up with count = 1 and no ids.
|
||||
*/
|
||||
if (count == 0 || idArray.length < 1) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
List<EventJoinVO> events = _eventJoinDao.searchByIds(idArray);
|
||||
|
|
|
|||
|
|
@ -130,6 +130,10 @@ public class EventJoinDaoImpl extends GenericDaoBase<EventJoinVO, Long> implemen
|
|||
|
||||
@Override
|
||||
public List<EventJoinVO> searchByIds(Long... ids) {
|
||||
// return empty collection if there are no ids.
|
||||
if (ids.length == 0) {
|
||||
return List.of();
|
||||
}
|
||||
SearchCriteria<EventJoinVO> sc = vrSearch.create();
|
||||
sc.setParameters("idIN", ids);
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue