You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Xingcan Cui (Jira)" <ji...@apache.org> on 2020/05/03 21:51:00 UTC
[jira] [Created] (SPARK-31632) The ApplicationInfo in KVStore may
be accessed before it's prepared
Xingcan Cui created SPARK-31632:
-----------------------------------
Summary: The ApplicationInfo in KVStore may be accessed before it's prepared
Key: SPARK-31632
URL: https://issues.apache.org/jira/browse/SPARK-31632
Project: Spark
Issue Type: Bug
Components: Spark Core, Web UI
Affects Versions: 3.0.0
Reporter: Xingcan Cui
While starting some local tests, I occasionally encountered the following exceptions for Web UI.
{noformat}
23:00:29.845 WARN org.eclipse.jetty.server.HttpChannel: /jobs/
java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:4191)
at org.apache.spark.util.kvstore.InMemoryStore$InMemoryIterator.next(InMemoryStore.java:467)
at org.apache.spark.status.AppStatusStore.applicationInfo(AppStatusStore.scala:39)
at org.apache.spark.ui.jobs.AllJobsPage.render(AllJobsPage.scala:266)
at org.apache.spark.ui.WebUI.$anonfun$attachPage$1(WebUI.scala:89)
at org.apache.spark.ui.JettyUtils$$anon$1.doGet(JettyUtils.scala:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
at org.apache.spark.ui.HttpSecurityFilter.doFilter(HttpSecurityFilter.scala:95)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:753)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:505)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:698)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:804)
at java.lang.Thread.run(Thread.java:748){noformat}
*Reason*
That is because {{AppStatusStore.applicationInfo()}} accesses an empty view (iterator) returned by {{InMemoryStore}}.
AppStatusStore
{code:java}
def applicationInfo(): v1.ApplicationInfo = {
store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
}
{code}
InMemoryStore
{code:java}
public <T> KVStoreView<T> view(Class<T> type){
InstanceList<T> list = inMemoryLists.get(type);
return list != null ? list.view() : emptyView();
}
{code}
During the initialization of {{SparkContext}}, it first starts the Web UI (SparkContext: L475 _ui.foreach(_.bind())) and then setup the {{LiveListenerBus}} thread (SparkContext: L608 {{setupAndStartListenerBus()}}) for dispatching the {{SparkListenerApplicationStart}} event (which will trigger writing the requested {{ApplicationInfo}} to {{InMemoryStore}}).
*Solution*
Since the {{applicationInfo()}} method is expected to always return a valid {{ApplicationInfo}}, maybe we can add a while-loop-check here to guarantee the availability of {{ApplicationInfo}}.
{code:java}
def applicationInfo(): v1.ApplicationInfo = {
var iterator = store.view(classOf[ApplicationInfoWrapper]).max(1).iterator()
while (!iterator.hasNext){
Thread.sleep(20)
iterator = store.view(classOf[ApplicationInfoWrapper]).max(1).iterator()
}
iterator.next().info
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org