-
Notifications
You must be signed in to change notification settings - Fork 21
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
Infinite Loop in scala.collection.mutable.HashTable #10436
Comments
I don't see anything obvious in the git history or the ticket database on this, but maybe I missed it. Perhaps someone else will recognize it and comment. Regardless, I am closing the ticket unless the bug can be demonstrated in a current version of Scala. |
I think I bumped into this using scala Thread dump stacktrace:
Relevant code snippet in Functions.scala:
I'm not sure how to reproduce this. I think it happened due to multithreading. |
|
I've also run into a similar issue on 2.11.11, with an infinite loop with stack trace:
This is likely due to concurrent use. I'd have expected and been happy with an exception being thrown. |
Honestly, it is very difficult to make your collections detect concurrent modification, and may have some overhead cost as well. Just look through the source code for |
Agree... I kinda half-wanted to reopen this in response to Bryce's report, but I'd be reluctant to get anybody's hopes up that this is likely to change/improve; I think it isn't. |
I think this is a known problem with a number of hash-map implementations. I haven't looked into it, but if there was an easy/performant way to not enter an infinite loop that would be great, but as already noted, it may not be trivial. |
I've also run into a similar issue on 2.11.8, with an infinite loop with stack trace:
with the code in Spark
|
@bingbai0912 You're using, in a distributed and multi threaded environment, a class that is both deprecated and doesn't pretend to be thread safe. I think that's the issue you need to solve. You'd have to at least make sure that the same parser isn't shared between threads, and probably best to use a JSON parser that's not deprecated. |
@bingbai0912 background on |
### What changes were proposed in this pull request? `EventLoggingListener.codecMap` change `mutable.HashMap` to `ConcurrentHashMap` ### Why are the changes needed? 2.x version of history server `EventLoggingListener.codecMap` is of type mutable.HashMap, which is not thread safe. This will cause the history server to suddenly get stuck and not work. The 3.x version was changed to `EventLogFileReader.codecMap` to `ConcurrentHashMap` type, so there is no such problem.(SPARK-28869) Multiple threads call `openEventLog`, `codecMap` is updated by multiple threads, `mutable.HashMap` may fall into an infinite loop during `resize`, resulting in history server not working. scala/bug#10436 PID 117049 0x1c939 ![image](https://user-images.githubusercontent.com/3898450/104753904-9239c280-5793-11eb-8a2d-89324ccfb92c.png) ![image](https://user-images.githubusercontent.com/3898450/104753921-9534b300-5793-11eb-99e6-51ac66051d2a.png) ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? exist ut Closes #31194 from cxzl25/SPARK-34125. Authored-by: sychen <sychen@ctrip.com> Signed-off-by: Jungtaek Lim <kabhwan.opensource@gmail.com>
scala version
:2.10.4java version
: java version "1.7.0_79" (64-Bit)When I run unit test by maven, It cause infinite loop every 3 or 4 times.
I make sure the HashMap or HashTable only visit or update in single thread.
My unit test mostly like:
I search others had same problem.
Also see:
It seems that has this problem few year ago.
It was already solved? If it was, please show the bug URL. Thank you.
Jstack info show below:
nid=0x39d9,nid=0x39a2 this two threads always had mostly 100% cpu-use in 'top' command in Linux.
2017-07-27 16:02:57
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.72-b15 mixed mode):
"Executor task launch worker-6" #1260 daemon prio=5 os_prio=0 tid=0x00007fc8903ea000 nid=0x39d9 runnable [0x00007fc87f8f7000]
java.lang.Thread.State: RUNNABLE
at scala.collection.mutable.HashTable$class.elemEquals(HashTable.scala:347)
at scala.collection.mutable.HashMap.elemEquals(HashMap.scala:39)
at scala.collection.mutable.HashTable$class.scala$collection$mutable$HashTable$$findEntry0(HashTable.scala:134)
at scala.collection.mutable.HashTable$class.findOrAddEntry(HashTable.scala:162)
at scala.collection.mutable.HashMap.findOrAddEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap.put(HashMap.scala:75)
at scala.collection.mutable.HashMap.update(HashMap.scala:80)
# business code
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:226)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:98)
# business code
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
# business code
at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1$$anonfun$apply$17.apply(RDD.scala:686)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1$$anonfun$apply$17.apply(RDD.scala:686)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:70)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
at org.apache.spark.scheduler.Task.run(Task.scala:70)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Executor task launch worker-5" #1257 daemon prio=5 os_prio=0 tid=0x00007fc8922fc800 nid=0x39a2 runnable [0x00007fc880400000]
java.lang.Thread.State: RUNNABLE
at scala.collection.mutable.HashTable$class.elemEquals(HashTable.scala:347)
at scala.collection.mutable.HashMap.elemEquals(HashMap.scala:39)
at scala.collection.mutable.HashTable$class.scala$collection$mutable$HashTable$$findEntry0(HashTable.scala:134)
at scala.collection.mutable.HashTable$class.findOrAddEntry(HashTable.scala:162)
at scala.collection.mutable.HashMap.findOrAddEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap.put(HashMap.scala:75)
at scala.collection.mutable.HashMap.update(HashMap.scala:80)
# business code
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:226)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:98)
# business code
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
# business code
at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1$$anonfun$apply$17.apply(RDD.scala:686)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1$$anonfun$apply$17.apply(RDD.scala:686)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:70)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
at org.apache.spark.scheduler.Task.run(Task.scala:70)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
JNI global references: 314
The text was updated successfully, but these errors were encountered: