Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Out of memory exception while retrieving all the issues of a project area

Subhajit Bhuiya March 15, 2019

I am getting Out of memory exception while retrieving all the issues of a project area. It has around 600K Jira issues. Here is my code

final SearchProvider searchProvider = ComponentAccessor.getComponent(SearchProvider.class);
try {
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
Query query = queryBuilder.where().project(projectId).and().updated().gt(dayAfter.getMillis()).buildQuery();
SearchResults searchResults = searchProvider.search(query, appUser, PagerFilter.getUnlimitedFilter());
return getIssuesFromResult(searchResults);
}
catch (SearchException e) {
logger.error(e.getMessage());
}

 

Can we do it more efficient way like using paging

1 answer

0 votes
Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 15, 2019

Hi @Subhajit Bhuiya

Here is the OOM getting thrown, in the SearchResults searchResults = ... ? or in the following line?

Do you need all the information SearchResults provides or are you looking for specific information? If so, perhaps you should considering creating a return type that will provide only the necessary information.

Alternatively, you could https://developer.atlassian.com/server/confluence/atlassian-cache-2-overview/ the SearchResults and paginate over those.

Hope the above helps, if not, please let us know what you are trying to accomplish with the method described and we may find a solution together.

Kind regards,

Rafael

Subhajit Bhuiya March 15, 2019

I am able to get rid of this by using paging like this

 

JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
queryBuilder.where().project(project.getId()).and().updated().gt(dayAfter.getMillis());
queryBuilder.orderBy().issueId(SortOrder.ASC);
com.atlassian.query.Query query = queryBuilder.buildQuery();
int startIndex = 0;
int limit = 50;
while(true){
PagerFilter filter = new PagerFilter(startIndex, limit);
SearchResults searchResults = searchProvider.search(query, appUser, filter);
List<Issue> issues = JiraManager.getIssuesFromResult(searchResults);
if(issues != null && issues.size() > 0){
// Do Something
}
startIndex += limit;
}else{
break;
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events