简体   繁体   English

将 Go 与 BigQuery 结合使用时上下文被取消

[英]Context Canceled when using Go with BigQuery

I am trying to insert a record to biqquery & here the code which does the insert.我正在尝试将记录插入到 biqquery 中,这里是执行插入的代码。

func (s *Storage) Insert(w *warehouse.WarehouseRecord) error {
   event, err := w.Marshal()
   if err != nil {
      return err
   }
   logger.Info("inserting record to big query")
   ins := s.client.Dataset(s.dataSet).Table(event.GetTableName()).Inserter()
   ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
   defer cancel()
   if err := ins.Put(ctx, event); err != nil {
      return err
   }
   return nil
}

When i run my application, the insert fails with error.当我运行我的应用程序时,插入失败并出现错误。 The error says context canceled , but I am not canceling the context from parent, I suspect its happening inside the client package. Have any one of you come across this error?错误说context canceled ,但我没有取消父上下文,我怀疑它发生在客户端 package 内部。你们中有人遇到过这个错误吗?

Post "https://bigquery.googleapis.com/bigquery/v2/projects/dinesh-dev/datasets/analytics_test/tables/agent/insertAll?alt=json&prettyPrint=false": context canceled{"error":"Post \"https://bigquery.googleapis.com/bigquery/v2/projects/dinesh-dev/datasets/analytics_test/tables/agent/insertAll?alt=json\u0026prettyPrint=false\": context canceled"

Perhaps the context you've given on initialisation of foo.NewClient(ctx, ...) is canceled.也许您在初始化foo.NewClient(ctx, ...)时给出的context已被取消。 This context should not be canceled, see doc :不应取消此上下文,请参阅文档

// Do not cancel the context passed to NewClient: dialing happens asynchronously and the context is used to refresh credentials in the background. // 不要取消传递给 NewClient 的上下文:拨号是异步发生的,上下文用于在后台刷新凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 权限被拒绝使用 API 密钥从 GAE 使用 Go 访问 Bigquery - Permission denied accessing Bigquery with Go from GAE using the API key 使用 Spark BigQuery 连接器查询 BigQuery 视图时未启用缓存 - Cache not enabled when querying BigQuery view using Spark BigQuery connector 使用 BigQuery 存储时 golang 中的 BigQuery 可为空类型写入 API - BigQuery nullable types in golang when using BigQuery storage write API 使用 to_dataframe() 作为 BigQuery 管理员角色时出现 BigQuery 权限错误 - BigQuery Permission error when using to_dataframe() as BigQuery Admin role Go - 由 gin.Context.JSON 返回时为空切片 - Go - empty slice when return by gin.Context.JSON Python 中的 Google BigQuery 查询在使用 result() 时有效,但在使用 to_dataframe() 时出现权限问题 - Google BigQuery query in Python works when using result(), but Permission issue when using to_dataframe() 在 Grafana 中使用 BigQuery 插件 - Using BigQuery plugin in Grafana 使用 BigQuery 进行加法和减法时出现 SyntaxError - SyntaxError when adding and subtracting with BigQuery 将 BigQuery 传输服务与 CSV 一起使用时,是否可以仅传输某些列? 不是,所有列? - When using BigQuery transfer service with a CSV is it possible to only transfer certain columns? Not, all columns? 使用条件停止 BigQuery 脚本 - Stop a BigQuery script using a condition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM