gpt4 book ai didi

apache-spark - 长时间正常运行后,Spark 有状态流作业在检查点到 S3 时挂起

转载 作者:行者123 更新时间:2023-12-04 04:13:49 25 4
gpt4 key购买 nike

我最近一直在对我们的 Spark Streaming 应用程序进行压力测试。压力测试每秒接收大约 20,000 条消息,消息大小在 200 字节 - 1K 之间变化到 Kafka,其中 Spark Streaming 每 4 秒读取一次批次。

我们的 Spark 集群运行在带有独立集群管理器的 1.6.1 版上,我们的代码使用 Scala 2.10.6。

经过大约 15-20 小时的运行,其中一个启动检查点(以 40 秒间隔完成)的执行程序被以下堆栈跟踪卡住并且永远不会完成:

java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.socketRead(SocketInputStream.java:116) java.net.SocketInputStream.read(SocketInputStream.java:170) java.net.SocketInputStream.read(SocketInputStream.java:141) sun.security.ssl.InputRecord.readFully(InputRecord.java:465) sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593) sun.security.ssl.InputRecord.read(InputRecord.java:532) sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:533) org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:401) org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177) org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131) org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:326) org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:277) org.jets3t.service.impl.rest.httpclient.RestStorageService.performRestHead(RestStorageService.java:1038) org.jets3t.service.impl.rest.httpclient.RestStorageService.getObjectImpl(RestStorageService.java:2250) org.jets3t.service.impl.rest.httpclient.RestStorageService.getObjectDetailsImpl(RestStorageService.java:2179) org.jets3t.service.StorageService.getObjectDetails(StorageService.java:1120) org.jets3t.service.StorageService.getObjectDetails(StorageService.java:575) org.apache.hadoop.fs.s3native.Jets3tNativeFileSystemStore.retrieveMetadata(Jets3tNativeFileSystemStore.java:174) sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:497) org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187) org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102) org.apache.hadoop.fs.s3native.$Proxy18.retrieveMetadata(Unknown Source) org.apache.hadoop.fs.s3native.NativeS3FileSystem.getFileStatus(NativeS3FileSystem.java:472) org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1424) org.apache.spark.rdd.ReliableCheckpointRDD$.writePartitionToCheckpointFile(ReliableCheckpointRDD.scala:168) org.apache.spark.rdd.ReliableCheckpointRDD$$anonfun$writeRDDToCheckpointDirectory$1.apply(ReliableCheckpointRDD.scala:136) org.apache.spark.rdd.ReliableCheckpointRDD$$anonfun$writeRDDToCheckpointDirectory$1.apply(ReliableCheckpointRDD.scala:136) org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66) org.apache.spark.scheduler.Task.run(Task.scala:89) org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745)



当被卡住时,spark 驱动程序拒绝继续处理传入的批次,并创建大量的排队批次积压,直到释放“卡住”的任务才能处理。

此外,查看 streaming-job-executor-0 下的驱动程序线程转储清楚地表明它正在等待这个任务完成:

java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:502) org.apache.spark.scheduler.JobWaiter.awaitResult(JobWaiter.scala:73) org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:612) org.apache.spark.SparkContext.runJob(SparkContext.scala:1832) org.apache.spark.SparkContext.runJob(SparkContext.scala:1845) org.apache.spark.SparkContext.runJob(SparkContext.scala:1922) org.apache.spark.rdd.ReliableCheckpointRDD$.writeRDDToCheckpointDirectory(ReliableCheckpointRDD.scala:135) org.apache.spark.rdd.ReliableRDDCheckpointData.doCheckpoint(ReliableRDDCheckpointData.scala:58) org.apache.spark.rdd.RDDCheckpointData.checkpoint(RDDCheckpointData.scala:74) org.apache.spark.rdd.RDD$$anonfun$doCheckpoint$1.apply$mcV$sp(RDD.scala:1682) org.apache.spark.rdd.RDD$$anonfun$doCheckpoint$1.apply(RDD.scala:1679) org.apache.spark.rdd.RDD$$anonfun$doCheckpoint$1.apply(RDD.scala:1679) org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150) org.apache.spark.rdd.RDD.doCheckpoint(RDD.scala:1678) org.apache.spark.rdd.RDD$$anonfun$doCheckpoint$1$$anonfun$apply$mcV$sp$1.apply(RDD.scala:1684) org.apache.spark.rdd.RDD$$anonfun$doCheckpoint$1$$anonfun$apply$mcV$sp$1.apply(RDD.scala:1684) scala.collection.immutable.List.foreach(List.scala:318)



有没有人遇到过这样的问题?

最佳答案

套接字挂起是由于 HttpClient 中的错误引起的org.jets3t 使用的库其中 SSL 握手不使用指定的超时。您可以找到问题详细信息 here .

此错误在 v4.5.1 以下的 HttpClient 版本中重现,并已修复。不幸的是,Spark 1.6.x 使用 v4.3.2,它没有提供的修复程序。

到目前为止,我想到了三种可能的解决方法:

  • 通过 spark.speculation 使用 Spark 的推测机制配置设置。这有助于解决挂起的边缘情况,因为它很少在负载下重现。请注意,这可能会在流式作业开始时导致一些误报,其中 spark 对运行中值任务的时间没有很好的印象,但这绝对不会导致明显的滞后。

    文档说:

    If set to "true", performs speculative execution of tasks. This means if one or more tasks are running slowly in a stage, they will be re-launched.



    您可以通过向 spark-submit 提供标志来打开它:
    spark-submit  \
    --conf "spark.speculation=true" \
    --conf "spark.speculation.multiplier=5" \

    有关您可以通过的不同设置的更多信息,请参阅 Spark Configuration
  • 手动将 HttpClient v4.5.1 或更高版本传递到 Sparks 类路径,因此它可以在它的 uber JAR 中加载这个 JAR 之前加载它。这可能有点困难,因为使用 Spark 的类加载过程有点麻烦。这意味着您可以执行以下操作:
    CP=''; for f in /path/to/httpcomponents-client-4.5.2/lib/*.jar; do CP=$CP$f:; done
    SPARK_CLASSPATH="$CP" sbin/start-master.sh # on your master machine
    SPARK_CLASSPATH="$CP" sbin/start-slave.sh 'spark://master_name:7077'

    或者干脆将 JAR 的特定版本更新为 SPARK_CLASSPATHspark-env.sh .
  • 更新到 Spark 2.0.0 . Spark 新版本使用 HttpClient v4.5.2 解决了这个问题。
  • 关于apache-spark - 长时间正常运行后,Spark 有状态流作业在检查点到 S3 时挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38606653/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com