英文:
AppendRows in Storage Write API Golang gets stuck in a loop
问题
我正在尝试使用Storage Write API将一些数据发送到BQ。我使用了这个示例:https://cloud.google.com/bigquery/docs/write-api-batch
当我的代码是平的时候,它可以工作,但是一旦我将它放入循环中,它就会在第二个循环步骤和res, err := ms.AppendRows(ctx, pfProto)
这一行永远卡住:
results := []*managedwriter.AppendResult{}
for i := 0; i < len(skus); i = i + PFStocksLimit {
lim := i + PFStocksLimit
if lim > len(skus)-1 {
lim = len(skus) - 1
}
stocks := getStocks(skus[i:lim])
pfProto := prepProto(gd, stocks)
res, err := ms.AppendRows(ctx, pfProto)
if err != nil {
log.Fatalf("AppendRows call error: %v", err)
}
results = append(results, res)
}
有趣的是,当我移除results = append(results, res)
时,它可以工作。我不明白这里出了什么问题。
英文:
I am trying to send some data to BQ using Storage Write API.
I use this example:
https://cloud.google.com/bigquery/docs/write-api-batch
When my code is flat it works, but as soon as I put it into a loop it stucks forever at the second loop step and res, err := ms.AppendRows(ctx, pfProto)
:
results := []*managedwriter.AppendResult{}
for i := 0; i < len(skus); i = i + PFStocksLimit {
lim := i + PFStocksLimit
if lim > len(skus)-1 {
lim = len(skus) - 1
}
stocks := getStocks(skus[i:lim])
pfProto := prepProto(gd, stocks)
res, err := ms.AppendRows(ctx, pfProto)
if err != nil {
log.Fatalf("AppendRows call error: %v", err)
}
results = append(results, res)
}
Funny enough when I remove results = append(results, res)
it works.
I do not understang what is wrong here.
答案1
得分: 1
我刚刚意识到这是一个关于大数据插入的错误,该问题已在此处报告:https://github.com/googleapis/google-cloud-go/issues/6321
解决方案:一次插入较少的行。
英文:
I just realized that this is a bug for big data inserts, the issue is reported here: https://github.com/googleapis/google-cloud-go/issues/6321
Solution: insert less rows at one time
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论