BigQueryTable.InsertRows throws Table xx not found intermittingly
BigQueryTable.InsertRows throws Table xx not found intermittingly
我们只是删除 table,创建 table,然后使用
插入数据
BigQueryTable table;
try
{
table = dataset.GetTable(tableName);
table.Delete();
}
catch
{
}
finally
{
table = dataset.CreateTable(tableName, schemaBuilder.Build());
}
table.InsertRows(rows);
它有效,但有时会抛出,
Exception while executing function: BigQueryExport Google.Apis.Requests.RequestError
Table xxxx not found. [404]
Errors [
Message[Table xxxx not found.] Location[ - ] Reason[notFound] Domain[global]
]
exception Google.GoogleApiException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
at Google.Apis.Requests.ClientServiceRequest`1+<ParseResponse>d__31.MoveNext (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Google.Apis.Requests.ClientServiceRequest`1.Execute (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at Google.Cloud.BigQuery.V2.BigQueryClientImpl.InsertRows (Google.Cloud.BigQuery.V2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=185c282632e132a0)
我们正在使用 google.cloud.bigquery.v2
版本 2.1.0
。
由于 table 创建是最终一致的,我在插入行时添加了重试选项,例如,
var policy = Policy
.Handle<GoogleApiException>()
.WaitAndRetry(new[]
{
TimeSpan.FromMinutes(1),
TimeSpan.FromMinutes(5),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(30),
TimeSpan.FromMinutes(60),
})
.Execute(() => table.InsertRows(rows));
这里提到了更多的方法来解决这个问题https://github.com/googleapis/google-cloud-dotnet/issues/8146
我们只是删除 table,创建 table,然后使用
插入数据 BigQueryTable table;
try
{
table = dataset.GetTable(tableName);
table.Delete();
}
catch
{
}
finally
{
table = dataset.CreateTable(tableName, schemaBuilder.Build());
}
table.InsertRows(rows);
它有效,但有时会抛出,
Exception while executing function: BigQueryExport Google.Apis.Requests.RequestError
Table xxxx not found. [404]
Errors [
Message[Table xxxx not found.] Location[ - ] Reason[notFound] Domain[global]
]
exception Google.GoogleApiException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
at Google.Apis.Requests.ClientServiceRequest`1+<ParseResponse>d__31.MoveNext (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Google.Apis.Requests.ClientServiceRequest`1.Execute (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at Google.Cloud.BigQuery.V2.BigQueryClientImpl.InsertRows (Google.Cloud.BigQuery.V2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=185c282632e132a0)
我们正在使用 google.cloud.bigquery.v2
版本 2.1.0
。
由于 table 创建是最终一致的,我在插入行时添加了重试选项,例如,
var policy = Policy
.Handle<GoogleApiException>()
.WaitAndRetry(new[]
{
TimeSpan.FromMinutes(1),
TimeSpan.FromMinutes(5),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(30),
TimeSpan.FromMinutes(60),
})
.Execute(() => table.InsertRows(rows));
这里提到了更多的方法来解决这个问题https://github.com/googleapis/google-cloud-dotnet/issues/8146