如本文所述,使用java存储api,https://cloud.google.com/bigquery/docs/write-api。当一个不可重试的错误发生时,按照此https://cloud.google.com/bigquery/docs/write-api#error_handling,写流将保持较长的生存期并刷新它。
我坚持默认流。我有两个表和不同的代码部分,负责编写每个表,维护自己的流编写器。
如果数据是流动的,一切都很好。没有错误。但是,我想测试刷新流写入器的工作,所以我等待默认的流超时(10分钟),这将关闭流,然后再次尝试写入。我可以很好地创建流,那里没有错误,但是对于其中一个表,我一直被取消的错误包装在一个预条件中失败,使我的代码一次又一次地刷新。
原始错误,因为流由于不活动而关闭。
! io.grpc.StatusRuntimeException: FAILED_PRECONDITION: Stream is closed due to com.google.api.gax.rpc.AbortedException: io.grpc.StatusRuntimeException: ABORTED: Closing the stream because it has been inactive for 600 seconds. Entity: projects/<id>/datasets/<id>/tables/<id>/_default
! at com.google.cloud.bigquery.storage.v1beta2.StreamWriterV2.appendInternal(StreamWriterV2.java:263)
! at com.google.cloud.bigquery.storage.v1beta2.StreamWriterV2.append(StreamWriterV2.java:234)
! at com.google.cloud.bigquery.storage.v1beta2.JsonStreamWriter.append(JsonStreamWriter.java:114)
! at com.google.cloud.bigquery.storage.v1beta2.JsonStreamWriter.append(JsonStreamWriter.java:89)在新流上进一步重复错误
! io.grpc.StatusRuntimeException: FAILED_PRECONDITION: Stream is closed due to com.google.api.gax.rpc.CancelledException: io.grpc.StatusRuntimeException: CANCELLED: io.grpc.Context was cancelled without error
! at com.google.cloud.bigquery.storage.v1beta2.StreamWriterV2.appendInternal(StreamWriterV2.java:263)
! at com.google.cloud.bigquery.storage.v1beta2.StreamWriterV2.append(StreamWriterV2.java:234)
! at com.google.cloud.bigquery.storage.v1beta2.JsonStreamWriter.append(JsonStreamWriter.java:114)
! at com.google.cloud.bigquery.storage.v1beta2.JsonStreamWriter.append(JsonStreamWriter.java:89)我不知道为什么会毫无差错地取消它。关于如何调试这个问题,或者关于如何维护和刷新长期存在的流写入器的建议,有什么建议吗?
发布于 2022-01-26 16:13:12
更新Java版本应该可以解决这个问题,因为对JsonStreamwriter添加了重新连接支持。它应该处理重试,而不是抛出此错误。
https://stackoverflow.com/questions/68627128
复制相似问题