I am trying to insert a record to biqquery & here the code which does the insert.
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?
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 offoo.NewClient(ctx, ...)
is canceled. This context should not be canceled, see doc: