scala.MatchError: null for all requests after some timepoint
scala.MatchError: null for all requests after some timepoint
我有一个相当大的 Play Framework 应用程序 运行 Play 2.4.3 正在生产中。我遇到过一些情况,突然所有对服务器的请求都开始出现以下 MatchError:
! @6p4o8d49h - Internal server error, for (GET) [/bookings/desk/suggest-products?term=&maxSize=50&page=1] ->
play.api.UnexpectedException: Unexpected exception[MatchError: null]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:261) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.http.HttpErrorHandlerExceptions.throwableToUsefulException(HttpErrorHandler.scala) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.http.DefaultHttpErrorHandler.throwableToUsefulException(DefaultHttpErrorHandler.java:169) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.http.DefaultHttpErrorHandler.onServerError(DefaultHttpErrorHandler.java:131) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError.apply(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError.apply(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$$anonfun$invokeWithContext.apply(JavaHelpers.scala:140) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$$anonfun$invokeWithContext.apply(JavaHelpers.scala:139) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$class.withContext(JavaHelpers.scala:151) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$.withContext(JavaHelpers.scala:160) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$class.invokeWithContext(JavaHelpers.scala:139) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$.invokeWithContext(JavaHelpers.scala:160) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter.onServerError(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$$anonfun$apply.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [com.typesafe.play.play-netty-server_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$$anonfun$apply.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [com.typesafe.play.play-netty-server_2.11-2.4.3.jar:2.4.3]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Failure$$anonfun$recover.apply(Try.scala:216) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Try$.apply(Try.scala:192) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Failure.recover(Try.scala:216) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover.apply(Future.scala:324) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover.apply(Future.scala:324) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [org.scala-lang.scala-library-2.11.7.jar:na]
at play.api.libs.iteratee.Execution$trampoline$.executeScheduled(Execution.scala:109) [com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:71) [com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Promise$class.complete(Promise.scala:55) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [org.scala-lang.scala-library-2.11.7.jar:na]
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39) [com.typesafe.akka.akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:399) [com.typesafe.akka.akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.11.7.jar:na]
Caused by: scala.MatchError: null
at play.core.j.JavaAction.apply(JavaAction.scala:97) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply$$anonfun$apply.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply$$anonfun$apply.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply.apply(Action.scala:104) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at scala.Option.map(Option.scala:146) ~[org.scala-lang.scala-library-2.11.7.jar:na]
at play.api.mvc.Action$$anonfun$apply.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply.apply(Action.scala:96) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$$anonfun$apply.apply(Iteratee.scala:536) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$$anonfun$apply.apply(Iteratee.scala:536) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [org.scala-lang.scala-library-2.11.7.jar:na]
... 6 common frames omitted
在第一个错误发生之前,日志看起来非常健康和正常,第一个异常是一些随机请求。在第一次请求命中此错误后,所有后续请求都会出现相同的错误,直到我们重新启动服务器。
从 play.core.j.JavaAction.apply(JavaAction.scala:97)
来看,错误似乎意味着返回的 Response 对象都是 null
。
我查看了发生这种情况时堆 space 使用情况的一些图表,发现内存使用量出现了巨大的峰值。我强烈怀疑 MatchErrors 隐藏了 OutOfMemoryError("Java heap space") 错误。
有什么方法可以阻止 scala.MatchError 隐藏实际的 OutOfMemoryError?
这是堆已满,Scala需要分配堆来做模式匹配的综合原因。
解决方案是修复导致 OutOfMemoryException 的任何原因,MatchError 是一个转移注意力的问题。这只是 运行 out of heap space.
的副作用
我有一个相当大的 Play Framework 应用程序 运行 Play 2.4.3 正在生产中。我遇到过一些情况,突然所有对服务器的请求都开始出现以下 MatchError:
! @6p4o8d49h - Internal server error, for (GET) [/bookings/desk/suggest-products?term=&maxSize=50&page=1] ->
play.api.UnexpectedException: Unexpected exception[MatchError: null]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:261) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.http.HttpErrorHandlerExceptions.throwableToUsefulException(HttpErrorHandler.scala) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.http.DefaultHttpErrorHandler.throwableToUsefulException(DefaultHttpErrorHandler.java:169) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.http.DefaultHttpErrorHandler.onServerError(DefaultHttpErrorHandler.java:131) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError.apply(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError.apply(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$$anonfun$invokeWithContext.apply(JavaHelpers.scala:140) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$$anonfun$invokeWithContext.apply(JavaHelpers.scala:139) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$class.withContext(JavaHelpers.scala:151) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$.withContext(JavaHelpers.scala:160) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$class.invokeWithContext(JavaHelpers.scala:139) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHelpers$.invokeWithContext(JavaHelpers.scala:160) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.j.JavaHttpErrorHandlerAdapter.onServerError(JavaHttpErrorHandlerAdapter.scala:22) [com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$$anonfun$apply.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [com.typesafe.play.play-netty-server_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$$anonfun$apply.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [com.typesafe.play.play-netty-server_2.11-2.4.3.jar:2.4.3]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Failure$$anonfun$recover.apply(Try.scala:216) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Try$.apply(Try.scala:192) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.util.Failure.recover(Try.scala:216) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover.apply(Future.scala:324) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Future$$anonfun$recover.apply(Future.scala:324) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [org.scala-lang.scala-library-2.11.7.jar:na]
at play.api.libs.iteratee.Execution$trampoline$.executeScheduled(Execution.scala:109) [com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:71) [com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.Promise$class.complete(Promise.scala:55) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [org.scala-lang.scala-library-2.11.7.jar:na]
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39) [com.typesafe.akka.akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:399) [com.typesafe.akka.akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.11.7.jar:na]
Caused by: scala.MatchError: null
at play.core.j.JavaAction.apply(JavaAction.scala:97) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply$$anonfun$apply.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply$$anonfun$apply.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply.apply(Action.scala:104) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply$$anonfun$apply.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at scala.Option.map(Option.scala:146) ~[org.scala-lang.scala-library-2.11.7.jar:na]
at play.api.mvc.Action$$anonfun$apply.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.mvc.Action$$anonfun$apply.apply(Action.scala:96) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$$anonfun$apply.apply(Iteratee.scala:536) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$$anonfun$apply.apply(Iteratee.scala:536) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24) [org.scala-lang.scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [org.scala-lang.scala-library-2.11.7.jar:na]
... 6 common frames omitted
在第一个错误发生之前,日志看起来非常健康和正常,第一个异常是一些随机请求。在第一次请求命中此错误后,所有后续请求都会出现相同的错误,直到我们重新启动服务器。
从 play.core.j.JavaAction.apply(JavaAction.scala:97)
来看,错误似乎意味着返回的 Response 对象都是 null
。
我查看了发生这种情况时堆 space 使用情况的一些图表,发现内存使用量出现了巨大的峰值。我强烈怀疑 MatchErrors 隐藏了 OutOfMemoryError("Java heap space") 错误。
有什么方法可以阻止 scala.MatchError 隐藏实际的 OutOfMemoryError?
这是堆已满,Scala需要分配堆来做模式匹配的综合原因。
解决方案是修复导致 OutOfMemoryException 的任何原因,MatchError 是一个转移注意力的问题。这只是 运行 out of heap space.
的副作用