Skip to content

Commit

Permalink
fix(pubsub): ignore grpc errors in ack/modack (#5796)
Browse files Browse the repository at this point in the history
* fix(pubsub): ignore invalid argument errors in ack/modack

* ignore all grpc errors for ack/modack

* remove reference to invalid argument

* fix wording in comment

* check for nil err
  • Loading branch information
hongalex committed Mar 28, 2022
1 parent 1ca4170 commit 4fb9aec
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions pubsub/iterator.go
Expand Up @@ -420,22 +420,10 @@ func (it *messageIterator) sendAck(m map[string]bool) bool {
return nil
}
default:
if err == nil {
return nil
}
// This addresses an error where `context deadline exceeded` errors
// not captured by the previous case causes fatal errors.
// See https://github.com/googleapis/google-cloud-go/issues/3060
if strings.Contains(err.Error(), "context deadline exceeded") {
// Context deadline exceeded errors here should be transparent
// to prevent the iterator from shutting down.
if err := gax.Sleep(cctx, bo.Pause()); err != nil {
return nil
}
continue
}
// Any other error is fatal.
return err
// TODO(b/226593754): by default, errors should not be fatal unless exactly once is enabled
// since acks are "fire and forget". Once EOS feature is out, retry these errors
// if exactly-once is enabled, which can be determined from StreamingPull response.
return nil
}
}
})
Expand Down Expand Up @@ -486,18 +474,17 @@ func (it *messageIterator) sendModAck(m map[string]bool, deadline time.Duration)
recordStat(it.ctx, ModAckTimeoutCount, 1)
return nil
default:
if err == nil {
return nil
}
// This addresses an error where `context deadline exceeded` errors
// not captured by the previous case causes fatal errors.
// See https://github.com/googleapis/google-cloud-go/issues/3060
if strings.Contains(err.Error(), "context deadline exceeded") {
if err != nil && strings.Contains(err.Error(), "context deadline exceeded") {
recordStat(it.ctx, ModAckTimeoutCount, 1)
return nil
}
// Any other error is fatal.
return err
// TODO(b/226593754): by default, errors should not be fatal unless exactly once is enabled
// since modacks are "fire and forget". Once EOS feature is out, retry these errors
// if exactly-once is enabled, which can be determined from StreamingPull response.
return nil
}
}
})
Expand Down

0 comments on commit 4fb9aec

Please sign in to comment.