“300秒内无法执行广播”如何处理?

Adi*_*l B 1 palantir-foundry foundry-code-workbooks

我正在尝试构建工作,但其中一个阶段间歇性失败,并出现以下错误:

Could not execute broadcast in 300 secs. You can increase the timeout for broadcasts via spark.sql.broadcastTimeout or disable broadcast join by setting spark.sql.autoBroadcastJoinThreshold to -1
Run Code Online (Sandbox Code Playgroud)

我应该如何处理这个错误?

ich*_*bon 5

首先,我们来谈谈该错误的含义。

来自官方 Spark 文档(http://spark.apache.org/docs/latest/programming-guide.html#broadcast-variables):

Broadcast variables allow the programmer to keep a read-only variable cached on each machine rather than shipping a copy of it with tasks. They can be used, for example, to give every node a copy of a large input dataset in an efficient manner. Spark also attempts to distribute broadcast variables using efficient broadcast algorithms to reduce communication cost.

根据我的经验,当输入数据集之一分区不佳时,通常会发生广播超时。我建议您查看数据集的分区并确保它们正确分区,而不是禁用广播。

我使用的经验法则是采用数据集的大小(以 MB 为单位)除以 100,并将分区数设置为该数字。由于 HDFS 块大小为 125 MB,我们希望将文件拆分为大约 125 MB,但由于它们不能完美分割,我们可以除以较小的数字以获得更多分区。

最主要的是,非常小的数据集(~<125 MB)位于单个分区中,因为网络开销太大!希望这可以帮助。