Merge pull request #477 from shapeblue/list_events_sql_error

List Events returns intermittent SQL exception.
This commit is contained in:
mprokopchuk 2024-09-09 16:41:20 -07:00 committed by GitHub
commit 2755e338d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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);