hatunina’s blog

メモと日記です

apache sparkでStackOverflowErrorとOutOfMemoryErrorが発生した時の対処

以下バージョンです。
dockerコンテナ内で起動しています。

>> pyspark --version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/spark/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.3.1
      /_/
                        
Using Scala version 2.11.8, OpenJDK 64-Bit Server VM, 1.8.0_171


以下本題です。

$SPARK_HOME/bin/spark-submit your_app.py

とかした時、

java.lang.StackOverflowError

ってなったらこう!

$SPARK_HOME/bin/spark-submit --driver-java-options -Xss10m your_app.py

もし、

java.lang.OutOfMemoryError: Java heap space

ってなったらさらにこう!

$SPARK_HOME/bin/spark-submit --driver-java-options -Xss10m --driver-memory 10g your_app.py

10mとか10gとかはてきとーに変えてください。
スタック領域が足りないよ!というエラーですが発生時に特にネストした処理は書いてないんですよね。。。
心当たりがあるとしたらFPGrowthminSupport低めでアソシエーションルールを計算していたことぐらい。

参考はこちら
[SPARK-18531] Apache Spark FPGrowth algorithm implementation fails with java.lang.StackOverflowError - ASF JIRA