Google bigquery 为什么GoogleBigQueryAPI返回的是400而不是500状态码?
为什么下面的GoogleBigQueryAPI调用是400“坏请求”,而不是500(或者更具体地说是503)?我通常不会重试400,因为这意味着我的请求有问题,但当我查看错误消息中的描述时,它看起来像是服务器端的临时错误。而且,当我重试时,响应是成功的Google bigquery 为什么GoogleBigQueryAPI返回的是400而不是500状态码?,google-bigquery,Google Bigquery,为什么下面的GoogleBigQueryAPI调用是400“坏请求”,而不是500(或者更具体地说是503)?我通常不会重试400,因为这意味着我的请求有问题,但当我查看错误消息中的描述时,它看起来像是服务器端的临时错误。而且,当我重试时,响应是成功的 com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request { "code" : 400, "errors" : [ { "
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "The job encountered an error during execution. Retrying the job may solve the problem.",
"reason" : "jobBackendError"
} ],
"message" : "The job encountered an error during execution. Retrying the job may solve the problem."
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
我排除了专有stacktrace的其余部分,但代码如下所示,其中SQL很简单,如->“select*fromproject.ds.table
orderby1”
根据大查询文档和正常的HTTP约定。我认为应该是500或503
backendError 500 or 503 This error returns when there is a temporary server failure such as a network connection problem or a server overload.
我在生产中观察到同样的问题,偶尔会出现HTTP 400错误消息。Python库将它作为BadRequest异常引发。 此异常很少出现,并且仅在重载情况下出现(许多并发查询同时运行) 这个问题在官方Python BigQuery客户端的repo上进行了描述。谷歌内部的一个问题被认为是不可行的,出于这样的动机: 连接错误是作为作业结果返回的唯一可重试的错误,因此您只需要添加重试作业的逻辑。如果作业返回400,则插入()。getQueryResult()返回400,并且错误原因设置为“jobBackendError”(这意味着作业因连接错误而失败),但我认为在这种情况下不能重用作业id 我目前在Google Support上有一个未解决的问题,要求他们将HTTP状态代码更改为500,或者至少在
jobBackendError
原因中记录
作为一种临时解决方法,您可以捕获所有HTTP 400异常,只重试那些具有
作业backendError
、backendError
、内部错误原因的异常,然后重新引发其他异常。是否有执行查询失败的作业ID?这可能有助于BigQuery工程师提供更多关于出错原因的信息。@ElliottBrossard否,引发了异常,但异常消息中似乎没有。我相信您也可以从BigQuery UI的“查询历史记录”或“工作历史记录”下查看。@ElliottBrossard这是一个很好的提示,但不幸的是,我多次运行相同的查询,所以我不知道是哪个作业失败了。我在“查询历史记录”下看到了许多结果,但在“工作历史记录”下没有看到任何结果。谢谢
backendError 500 or 503 This error returns when there is a temporary server failure such as a network connection problem or a server overload.