openequella / openEQUELLA

Core openEQUELLA sources
https://openequella.github.io/
Apache License 2.0
42 stars 44 forks source link

SQL Exception on Advanced Searches in new UI #2605

Closed cbeach47 closed 3 years ago

cbeach47 commented 3 years ago

Describe the bug Clicking on an advanced search in the new UI fails with a SQLException. Only happens in the new UI

To Reproduce Steps to reproduce the behavior:

  1. Turn on the new UI and the new search UI
  2. Navigate to the search UI
  3. click on an advanced search
  4. note failure

Expected behavior The advanced search widgets to show up.

Screenshots N/A

Stacktrace

<tr><td>14:51:31,418</td><td>9088395d-6e66-4483-be06-b4ee75064d47</td><td><font color="#993300"><strong>ERROR</strong></font></td><td>RestEasyExceptionMapper</td>
<td>REST API error</td></tr>
<tr><td bgcolor="#993300" style="color:White; font-size : xx-small;" colspan="5">com.google.common.util.concurrent.UncheckedExecutionException: java.sql.SQLException: Connection is closed
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4806)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry.getTreeForPath(TreeRegistry.java:150)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry.getTreeForPath(TreeRegistry.java:93)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.api.LegacyContentApi.withTreePath(LegacyContentApi.scala:311)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.api.LegacyContentApi.submit(LegacyContentApi.scala:452)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at sun.reflect.GeneratedMethodAccessor569.invoke(Unknown Source)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at java.lang.reflect.Method.invoke(Method.java:498)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.remoting.resteasy.RestEasyServlet.service(RestEasyServlet.java:140)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.dispatcher.ServletDispatcher.dispatch(ServletDispatcher.java:95)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.dispatcher.RequestDispatchFilter.doFilter(RequestDispatchFilter.java:91)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:880)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1601)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at java.lang.Thread.run(Thread.java:748)
<br>&nbsp;&nbsp;&nbsp;&nbsp;Caused by: java.sql.SQLException: Connection is closed
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection.lambda$getClosedConnection$0(ProxyConnection.java:515)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.sun.proxy.$Proxy140.prepareStatement(Unknown Source)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at io.doolse.simpledba.jdbc.JDBCQueries$.$anonfun$prepareAndQuery$default$4$1(JDBCQueries.scala:368)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at io.doolse.simpledba.jdbc.JDBCQueries$.$anonfun$prepareAndQuery$2(JDBCQueries.scala:377)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:87)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.startCancelable(IORunLoop.scala:41)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOBracket$BracketStart.run(IOBracket.scala:90)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.Trampoline.cats$effect$internals$Trampoline$$immediateLoop(Trampoline.scala:67)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.Trampoline.startLoop(Trampoline.scala:35)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.TrampolineEC$JVMTrampoline.super$startLoop(TrampolineEC.scala:90)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.TrampolineEC$JVMTrampoline.$anonfun$startLoop$1(TrampolineEC.scala:90)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.TrampolineEC$JVMTrampoline.startLoop(TrampolineEC.scala:90)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.Trampoline.execute(Trampoline.scala:43)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.TrampolineEC.execute(TrampolineEC.scala:42)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:70)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:50)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:141)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.start(IORunLoop.scala:34)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOBracket$.$anonfun$apply$1(IOBracket.scala:43)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOBracket$.$anonfun$apply$1$adapted(IOBracket.scala:33)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$RestartCallback.start(IORunLoop.scala:352)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:124)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.$anonfun$suspendAsync$1(IORunLoop.scala:264)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.$anonfun$suspendAsync$1$adapted(IORunLoop.scala:263)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$RestartCallback.start(IORunLoop.scala:352)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:124)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IORunLoop$.start(IORunLoop.scala:34)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.IO.unsafeRunAsync(IO.scala:264)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.internals.IOPlatform$.unsafeResync(IOPlatform.scala:39)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.IO.unsafeRunTimed(IO.scala:331)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at cats.effect.IO.unsafeRunSync(IO.scala:246)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.core.db.RunWithDB$.executeWithHibernate(RunWithDB.scala:54)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.settings.UISettingsJava$.getUISettings(UISettings.scala:56)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.settings.UISettingsJava.getUISettings(UISettings.scala)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.selection.section.SelectionSummarySection.registered(SelectionSummarySection.java:130)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.registerSectionsInternal(DefaultSectionTree.java:250)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.registerSectionsInternal(DefaultSectionTree.java:221)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.registerSectionsInternal(DefaultSectionTree.java:237)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.registerSectionsInternal(DefaultSectionTree.java:221)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.registerSectionsInternal(DefaultSectionTree.java:237)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.setRootNode(DefaultSectionTree.java:97)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.generic.DefaultSectionTree.&lt;init&gt;(DefaultSectionTree.java:82)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry.createTree(TreeRegistry.java:166)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry.access$200(TreeRegistry.java:72)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry$TreeMaker.apply(TreeRegistry.java:108)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.tle.web.sections.registry.TreeRegistry$TreeMaker.apply(TreeRegistry.java:96)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:166)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3445)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2194)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2153)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2043)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache.get(LocalCache.java:3849)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3873)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4798)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4804)
<br>&nbsp;&nbsp;&nbsp;&nbsp;    ... 46 more
</td></tr>

Platform:

Additional context The old UI works for this flow

edalex-ian commented 3 years ago

Wow! SimpleDBA makes for a good stack trace with the cats and monads.

That all aside though, seems to be in the retrieval of UI Settings. This (java.sql.SQLException: Connection is closed) has popped up from time to time in our general testing, but for us Advanced Searches have not been an issue. Do you have any thoughts on this @PenghaiZhang

PenghaiZhang commented 3 years ago

Yes. I have spent a few hours investigating this issue. Actually, it did happen in Advanced Searches when I used a normal user rather than TLE_ADMINISTRATOR. So my first reaction was this was a ACL issue. But later on I found that this issue is caused by reading the UI Settings in SelectionSummarySection.

I have briefly mentioned in slack that the fix would be using the cached UI settings rather than calling UISettingsJava.getUISettings() because this method connects to DB whenever it gets called.

cathfitz commented 3 years ago

@cbeach47 I did grant SEARCH_POWER_SEARCH to my user and it fixed the problem for me

mrblippy commented 3 years ago

I tested this with multiple users, with different combinations of ACLs. The 500 error no longer happens.