Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException in sitesearch portlet #28779

Closed
waqasakramdot opened this issue Jun 6, 2024 · 4 comments · Fixed by #29458
Closed

IndexOutOfBoundsException in sitesearch portlet #28779

waqasakramdot opened this issue Jun 6, 2024 · 4 comments · Fixed by #29458
Assignees
Labels
LTS: Excluded Ticket that has been excluded from at least one LTS OKR : Customer Support Owned by Scott Priority : 2 High QA : Approved Release : 23.10.24 v16 Included in LTS patch release 23.10.24 v16 Release : 24.04.24 v8 Included in LTS patch release 24.04.24 v8 Release : 24.08.20 AI Fixed Team : Bug Fixers Type : Defect

Comments

@waqasakramdot
Copy link
Contributor

waqasakramdot commented Jun 6, 2024

Parent Issue

No response

Problem Statement

A customer reported an issue related to sitesearch and in the logs shows.


40: 
41: 
42: 
43: List<String> indices=ssapi.listIndices();
44: List<String> closedIndices=ssapi.listClosedIndices();
45: 
46: Map<String, IndexStats> indexInfo = esapi.getIndicesStats();


Stacktrace:
org.apache.jasper.JasperException: An exception occurred processing [/html/portlet/ext/sitesearch/site_search_index_stats.jsp] at line [43]

40: 
41: 
42: 
43: List<String> indices=ssapi.listIndices();
44: List<String> closedIndices=ssapi.listClosedIndices();
45: 
46: Map<String, IndexStats> indexInfo = esapi.getIndicesStats();


Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:610) ~[jasper.jar:9.0.60]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:499) ~[jasper.jar:9.0.60]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379) ~[jasper.jar:9.0.60]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:327) ~[jasper.jar:9.0.60]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[servlet-api.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-websocket.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotmarketing.filters.CMSFilter.doFilterInternal(CMSFilter.java:181) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at com.dotmarketing.filters.CMSFilter.doFilter(CMSFilter.java:61) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.visitor.filter.servlet.VisitorFilter.doFilter(VisitorFilter.java:81) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.vanityurl.filters.VanityURLFilter.doFilter(VanityURLFilter.java:114) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) ~[urlrewritefilter-4.0.4.jar:4.0.4]
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) ~[urlrewritefilter-4.0.4.jar:4.0.4]
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) ~[urlrewritefilter-4.0.4.jar:4.0.4]
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389) ~[urlrewritefilter-4.0.4.jar:4.0.4]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotmarketing.filters.TimeMachineFilter.doFilter(TimeMachineFilter.java:137) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotmarketing.filters.ThreadNameFilter.doFilter(ThreadNameFilter.java:88) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotmarketing.filters.CookiesFilter.doFilter(CookiesFilter.java:53) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotmarketing.filters.CharsetEncodingFilter.doFilter(CharsetEncodingFilter.java:99) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at com.dotcms.filters.NormalizationFilter.doFilter(NormalizationFilter.java:89) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[catalina.jar:9.0.60]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[catalina.jar:9.0.60]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687) ~[catalina.jar:9.0.60]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[catalina.jar:9.0.60]
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:769) ~[catalina.jar:9.0.60]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[catalina.jar:9.0.60]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[catalina.jar:9.0.60]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-coyote.jar:9.0.60]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-coyote.jar:9.0.60]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) ~[tomcat-coyote.jar:9.0.60]
at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701) ~[tomcat-coyote.jar:9.0.60]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-coyote.jar:9.0.60]
at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190) ~[tomcat-coyote.jar:9.0.60]
at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633) ~[tomcat-coyote.jar:9.0.60]
at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611) ~[tomcat-coyote.jar:9.0.60]
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127) ~[?:?]
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:439) ~[?:?]
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:191) ~[?:?]
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213) ~[?:?]
at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:306) ~[?:?]
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 3
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:372) ~[?:?]
at java.util.ArrayList.remove(ArrayList.java:536) ~[?:?]
at com.dotcms.enterprise.publishing.sitesearch.ESSiteSearchAPI.setDefaultToSpecificPosition(ESSiteSearchAPI.java:168) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at com.dotcms.enterprise.publishing.sitesearch.ESSiteSearchAPI.listIndices(ESSiteSearchAPI.java:150) ~[dotcms_23.10.24_lts_v2_5374aed.jar:?]
at org.apache.jsp.html.portlet.ext.sitesearch.site_005fsearch_005findex_005fstats_jsp._jspService(site_005fsearch_005findex_005fstats_jsp.java:553) ~[?:?]
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[jasper.jar:9.0.60]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[servlet-api.jar:4.0.FR]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466) ~[jasper.jar:9.0.60]
... 77 more

Steps to Reproduce

  1. Create a few SS indices
  2. Set one as default
  3. Delete the default SS index directly from ES:
curl -X DELETE "http://localhost:9200/{index_name}"
  1. Flush Cache
  2. Try to create a new SS index

This line throws an error

Because list.indexOf(defaultIndice); returns -1 if default indices are not there in the list

final int index = list.indexOf(defaultIndice);
                    //change the element defaultIndex to the first position of the arraylist if it is not yet
                    if (index != 0) {
                        list.remove(index);
                        list.add(indexPosition, defaultIndice);
                    }

The root cause is here.
indiciesAPI.loadIndicies() returns different results

final String defaultIndice = indiciesAPI.loadIndicies().getSiteSearch();

Acceptance Criteria

The logic error should handle and indexoutofbound should never return if difference in indeces

dotCMS Version

24.*

Proposed Objective

Customer Support

Proposed Priority

Priority 4 - Trivial

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://dotcms.zendesk.com/agent/tickets/116403

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@erickgonzalez
Copy link
Contributor

Another Customer hitting this: https://dotcms.zendesk.com/agent/tickets/116552

Workaround

It was to remove the default SS index directly from the DB and flush the cache. Afterwards, the portlet started to show up, and we were able to set up the SS index default again.

@erickgonzalez erickgonzalez moved this from New to Current Sprint Backlog in dotCMS - Product Planning Jun 17, 2024
@dsolistorres dsolistorres self-assigned this Jun 25, 2024
@dsolistorres dsolistorres moved this from Current Sprint Backlog to In Progress in dotCMS - Product Planning Jun 25, 2024
@dsolistorres dsolistorres removed their assignment Jun 25, 2024
@dsolistorres dsolistorres moved this from In Progress to Current Sprint Backlog in dotCMS - Product Planning Jun 25, 2024
@erickgonzalez erickgonzalez moved this from Current Sprint Backlog to In Progress in dotCMS - Product Planning Jul 15, 2024
@erickgonzalez erickgonzalez self-assigned this Jul 15, 2024
@erickgonzalez
Copy link
Contributor

erickgonzalez commented Jul 30, 2024

I've observed this issue with customers a few times; the most common cause is the non-existence of the Default index. Let's implement validation for this and also add a WARN log when the Default index isn't present.

@bryanboza
Copy link
Contributor

Fixed, this is working as expected, no error after delete the index

Tested on [ trunk_78bb755 ] // Docker

@erickgonzalez erickgonzalez added LTS: Needs Backport Ticket that will be added to LTS LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch labels Aug 20, 2024
@erickgonzalez erickgonzalez removed the LTS: Needs Backport Ticket that will be added to LTS label Aug 30, 2024
erickgonzalez added a commit that referenced this issue Sep 4, 2024
@erickgonzalez erickgonzalez added the LTS: Excluded Ticket that has been excluded from at least one LTS label Sep 5, 2024
@erickgonzalez
Copy link
Contributor

This does not apply to 23.01 LTS since the code doesn't exist.

erickgonzalez added a commit that referenced this issue Sep 9, 2024
@erickgonzalez erickgonzalez added Release : 24.04.24 v8 Included in LTS patch release 24.04.24 v8 Release : 23.10.24 v16 Included in LTS patch release 23.10.24 v16 and removed LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS: Excluded Ticket that has been excluded from at least one LTS OKR : Customer Support Owned by Scott Priority : 2 High QA : Approved Release : 23.10.24 v16 Included in LTS patch release 23.10.24 v16 Release : 24.04.24 v8 Included in LTS patch release 24.04.24 v8 Release : 24.08.20 AI Fixed Team : Bug Fixers Type : Defect
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants