Glue etl 作业无法使用dynamic frame 写入 Redshift,原因是什么?

0

【以下的问题经过翻译处理】 我们发现使用Glue dynamic frame将数据写入Redshift时,如果输入文件大于1GB,会出现错误。 设置: Redshift群集:2个DC2节点 Glue作业

temp_df = glueContext.create_dynamic_frame.from_options(connection_type="s3", format="csv", connection_options={"paths": [source]}, format_options={"withHeader": True, "separator": ","}, transformation_ctx="path={}".format(source)).toDF()

    redshift_df = DynamicFrame.fromDF(output_df, glueContext, "redshift_df")
    datasink4 = glueContext.write_dynamic_frame.from_jdbc_conf(frame=redshift_df, catalog_connection="pilot-rs", connection_options={"preactions": "truncate table tablename;", "dbtable": "tablename", "database": "dev"}, redshift_tmp_dir='s3://bucket/path/', transformation_ctx="datasink4")

观察: 当输入文件小于1GB时,代码可以正常工作并将数据写入Redshift表中。 当输入文件大小大于1GB时,作业运行时间约在10分钟时失败。

错误:

An error occurred while calling o260.save. Timeout waiting for connection from pool

并且有时还会出现以下错误:

“An error occurred while calling o334.pyWriteDynamicFrame. Timeout waiting for connection from pool"

Glue错误日志片段

Caused by: com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
	at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:286)
	at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:263)

profile picture
エキスパート
質問済み 5ヶ月前23ビュー
1回答
0

【以下的回答经过翻译处理】 在尝试连接到源(s3)或接收器(s3 的临时位置)时,似乎没有足够的 HTTPConnection 对象。我之前在EMR中遇到过类似问题,可以将 fs.s3.maxConnections 设置为较高的值以增加连接池大小。你可以参照1 中提到的方法来增加这个值。可以通过以下方式来设置这个值:

scala: sparkcontext.hadoopConfiguration.set("spark.hadoop.fs.s3.maxConnections", 1000)

python: sparkcontext._jsc.hadoopConfiguration().set('spark.hadoop.fs.s3.maxConnections', '1000')

问题可能是由于获取和写入大文件时,HTTP 连接需要比正常情况下等待更长的时间,连接池出现不足导致错误发生。

profile picture
エキスパート
回答済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン