Skip to content

Commit

Permalink
redis.Client#XReadUntilResult(): also re-try timeout errors
Browse files Browse the repository at this point in the history
An XREAD with BLOCK sets a socket timeout of BLOCK+10s.
If reading the response hits that timeout, it's not re-tried due to BLOCK.
Hence, we have to re-ty it by ourselves.
  • Loading branch information
Al2Klimov committed Aug 16, 2024
1 parent 715b56e commit 2efd1f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ func (c *Client) XReadUntilResult(ctx context.Context, a *redis.XReadArgs) ([]re
cmd := c.XRead(ctx, a)
streams, err := cmd.Result()
if err != nil {
if errors.Is(err, redis.Nil) {
continue
if errors.Is(err, redis.Nil) || retry.Retryable(err) {
select {
case <-ctx.Done():
default:
continue
}
}

return streams, WrapCmdErr(cmd)
Expand Down

0 comments on commit 2efd1f7

Please sign in to comment.