[英]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.