-
Bug
-
Resolution: Fixed
-
Low
-
7.0.11, 7.1.10, 7.3.8, 7.5.0, 7.4.4, 7.2.11
-
None
-
7
-
2
-
Severity 3 - Minor
-
3
-
Behaviour
Adding Fix Version or Affected Version to basic mode search may take several seconds to complete.
This slowdown is visible if JIRA has many projects 1_000+ and many version 10_000+
one can observe following stack traces which execute following URL [BASE_URL]/secure/QueryComponentRendererEdit!Default.jspa
... <- many many more of Iterators$5.next at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$5.next(Iterators.java:558) at com.google.common.collect.Iterators$7.computeNext(Iterators.java:651) at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143) at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138) at com.google.common.collect.Iterators.addAll(Iterators.java:361) at com.google.common.collect.Lists.newArrayList(Lists.java:160) at com.google.common.collect.Lists.newArrayList(Lists.java:144) at com.atlassian.jira.project.version.DefaultVersionManager.filterVersions(DefaultVersionManager.java:514) at com.atlassian.jira.project.version.DefaultVersionManager.getAllVersionsForProjects(DefaultVersionManager.java:619) at com.atlassian.jira.issue.search.searchers.renderer.AbstractVersionRenderer.getValidOptions(AbstractVersionRenderer.java:125) at com.atlassian.jira.issue.search.searchers.renderer.AbstractVersionRenderer.getValidOptions(AbstractVersionRenderer.java:37) at com.atlassian.jira.issue.search.searchers.renderer.AbstractProjectConstantsRenderer.getOptions(AbstractProjectConstantsRenderer.java:112) at com.atlassian.jira.issue.search.searchers.renderer.AbstractProjectConstantsRenderer.addEditParameters(AbstractProjectConstantsRenderer.java:105) at com.atlassian.jira.issue.search.searchers.renderer.AbstractProjectConstantsRenderer.getEditHtml(AbstractProjectConstantsRenderer.java:94) at com.atlassian.jira.components.query.DefaultSearcherService.getEditHtml(DefaultSearcherService.java:412) at com.atlassian.jira.components.query.DefaultSearcherService.getValueResults(DefaultSearcherService.java:230) at com.atlassian.jira.components.query.DefaultSearcherService.getSearchResults(DefaultSearcherService.java:165) at com.atlassian.jira.components.query.DefaultSearcherService.searchWithJql(DefaultSearcherService.java:160) at com.atlassian.jira.components.query.QueryAction.doJql(QueryAction.java:40) at sun.reflect.GeneratedMethodAccessor2229.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70) at webwork.util.InjectionUtils.invoke(InjectionUtils.java:56) at webwork.action.ActionSupport.invokeCommand(ActionSupport.java:438) at webwork.action.ActionSupport.execute(ActionSupport.java:157) at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63) at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39) at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31) at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16) at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35) at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:225) at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:154) at com.atlassian.jira.web.dispatcher.JiraWebworkActionDispatcher.service(JiraWebworkActionDispatcher.java:141) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.atlassian.jira.web.filters.JiraLastFilter.lambda$doFilter$0(JiraLastFilter.java:35) at com.atlassian.jira.web.filters.JiraLastFilter$$Lambda$870/1680887520.doFilter(Unknown Source) at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:74) at com.atlassian.jira.web.filters.JiraLastFilter.doFilter(JiraLastFilter.java:33) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.atlassian.jira.web.filters.XContentTypeOptionsNoSniffFilter.doFilter(XContentTyp
Expected behaviour
requests to /secure/QueryComponentRendererEdit!Default.jspa should be fast
Root cause
In DefaultVersionManager there is following code
Iterable<Version> allVersions = Collections.emptyList(); for (Project project : projects) { final Iterable<Version> projectVersions = versionStore.getVersionsByProject(project.getId()); allVersions = Iterables.concat(allVersions, projectVersions); }
This is creating cubic complexity iterable which is then converted to an ArrayList.
We should use either streams or simple foreach loop with collector.