【问题标题】:Trying to run a data flow job in us central 1 region but source and target is in asia-south1尝试在我们中部 1 区域运行数据流作业,但源和目标位于 asia-south1
【发布时间】:2021-03-12 08:21:09
【问题描述】:

想要检查帖子“https://stackoverflow.com/questions/37298504/google-dataflow-job-and-bigquery-failing-on-different-regions?rq=”中也提到的类似错误1"

我在数据流作业中遇到了类似的问题,出现如下错误

2021-03-10T06:02:26.115216545ZWorkflow failed. Causes: S01:Read File from GCS/Read+String To BigQuery Row+Write to BigQuery/NativeWrite failed., BigQuery import job "dataflow_job_15712075439082970546-B" failed., BigQuery job "dataflow_job_15712075439082970546-B" in project "whr-asia-datalake-prod" finished with error(s): errorResult: Cannot read and write in different locations: source: US, destination: asia-south1, error: Cannot read and write in different locations: source: US, destination: asia-south1

这是我尝试使用云函数触发器运行代码时出现的错误。请在下面找到云功能代码。我的源数据和目标大查询数据集都位于 asia south 1

"""
Google cloud funtion used for executing dataflow jobs.
"""

from googleapiclient.discovery import build
import time

def df_load_function(file, context):
    filesnames = [
        '5667788_OPTOUT_',
        'WHR_AD_EMAIL_CNSNT_RESP_'
    ]

    # Check the uploaded file and run related dataflow jobs.
    for i in filesnames:
        if 'inbound/{}'.format(i) in file['name']:
            print("Processing file: {filename}".format(filename=file['name']))

            project = '<my project>'
            inputfile = 'gs://<my bucket>/inbound/' + file['name']
            job = 'df_load_wave1_{}'.format(i)
            template = 'gs://<my bucket>/template/df_load_wave1_{}'.format(i)
            location = 'us-central1'
           
            dataflow = build('dataflow', 'v1b3', cache_discovery=False)
            request = dataflow.projects().locations().templates().launch(
                projectId=project,
                gcsPath=template,
                location=location,
                body={
                    'jobName': job,
                    "environment": {
                    "workerZone": "us-central1-a"
                }
                }
            )

            # Execute the dataflowjob
            response = request.execute()
            
            job_id = response["job"]["id"]

我将 location 和 workerzone 分别保留为 us-central1 和 us-central1-a。由于一些资源问题,我需要在 us central 1 中运行我的数据流作业,但从 asia-south1 读取和写入数据。我还需要在云功能中添加什么,以便区域和区域都是 us-central1,但数据是从 asia south 1 读取和写入的。

但是,当我使用以下命令使用 cloud shell 手动运行我的作业时,它可以正常工作并加载数据。这里 region 和 zone 都是 us-central1

python -m <python script where the data is read from bucket and load big query> \

--project <my_project> \

--region us-central1 \

--runner DataflowRunner \

--staging_location gs://<bucket_name>/staging \

--temp_location gs://<bucket_name>/temp \

--subnetwork https://www.googleapis.com/compute/v1/projects/whr-ios-network/regions/us-central1/subnetworks/<subnetwork> \

--network projects/whr-ios-network/global/networks/<name> \

--zone us-central1-a \

--save_main_session

请帮助任何人。一直在努力解决这个问题。

【问题讨论】:

  • 你好@cahen,我知道你也有类似的问题。你能告诉我你是怎么解决的吗?
  • 将来自不同区域的资源用于源数据和目标数据并不是最佳做法。这会大大减慢你的进程。我建议您应该将数据源和目标迁移到另一个没有资源问题的区域。

标签: google-bigquery google-cloud-functions google-cloud-dataflow


【解决方案1】:

我能够修复以下错误 “2021-03-10T06:02:26.115216545ZWorkflow 失败。原因:S01:从 GCS 读取文件/读取+字符串到 BigQuery 行+写入 BigQuery/NativeWrite 失败。,BigQuery 导入作业“dataflow_job_15712075439082970546-B”失败。,BigQuery 作业项目“whr-asia-datalake-prod”中的“dataflow_job_15712075439082970546-B”完成错误:errorResult:无法在不同位置读写:源:美国,目的地:asia-south1,错误:无法读写不同地点:来源:美国,目的地:asia-south1"

我刚刚通过云功能更改以添加我的 asia-south 存储桶位置的临时位置,因为虽然我在创建模板时提供了 asia-south1 的 tmp 位置,但我的数据流作业中的 bigquery IO 试图使用us-central1 而不是 asia-south1 的临时位置,因此出现上述错误。

【讨论】:

    猜你喜欢
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    • 2021-02-02
    相关资源
    最近更新 更多