googleapis / googleapis/google-cloud-ruby

Pub/Sub: Retries when publishing

オープン
#20,573 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
api: pubsub type: cleanup
主要言語
Ruby
スター
1.4k
フォーク
578
平均マージ
1日 11時間
マージ済み PR(30日)
166

説明

#### Environment details

- OS: Ubuntu
- Ruby version: 3.1.2
- Gem name and version: `google-cloud-pubsub (2.15.1)`

#### Steps to reproduce

Not sure if this is a bug or intended, but two things:

1. If an error happens during publishing, using the async publisher, it is not retried unless you also supply an ordering key:
```ruby
rescue StandardError => e
items = batch.items

unless batch.ordering_key.empty?
retry if publish_batch_error_retryable? e # why are retries only done when ordering key present?
```
This was added in: https://github.com/googleapis/google-cloud-ruby/pull/3685. How come retrying in case of errors should not be done if you *don't* have an ordering key? Or is that a bug?

2. If you do have an ordering key, it will retry any of the following errors, indefinitely:
```ruby
PUBLISH_RETRY_ERRORS = [
GRPC::Cancelled, GRPC::DeadlineExceeded, GRPC::Internal,
GRPC::ResourceExhausted, GRPC::Unauthenticated, GRPC::Unavailable
].freeze
```
Consulting the documentation (https://cloud.google.com/pubsub/docs/reference/error-codes) it looks like some of these are incorrect. For instance `GRPC::Unauthenticated` should *not* be retried, and `GRPC::ResourceExhausted` should be retried with exponential backoff. It seems like it would be a problem if for instance `GRPC::Unauthenticated` keeps retrying forever?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、Ruby 3.1.2 と google-cloud-pubsub 2.15.1 のコンテキストで、publish_batch_error_retryable? と PUBLISH_RETRY_ERRORS 周辺の非同期パブリッシャーのエラーハンドリングを追跡します。Pub/Sub のエラーコードのドキュメントおよび PR 3685 とリトライの動作を比較し、ordering keys を使用する場合と使用しない場合のパブリッシングに対して、有限で適切なリトライを定義します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ruby
領域
distributed-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。