Skip to content

Commit 3d8607d

Browse files
authored
Do not stop retrying based on earlier good message from the stream (#313)
- Usually the pattern is to establish a stream and read messages in the loop until io.EOF. If the server become unavailable after sending a good message in the stream, the client has to retry from establish stream and handle the backoff logic.
1 parent df0f91b commit 3d8607d

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

retry/retry.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ func StreamClientInterceptor(optFuncs ...CallOption) grpc.StreamClientIntercepto
136136
type serverStreamingRetryingStream struct {
137137
grpc.ClientStream
138138
bufferedSends []interface{} // single message that the client can sen
139-
receivedGood bool // indicates whether any prior receives were successful
140139
wasClosedSend bool // indicates that CloseSend was closed
141140
parentCtx context.Context
142141
callOpts *options
@@ -209,17 +208,8 @@ func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error {
209208
}
210209

211210
func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m interface{}) (bool, error) {
212-
s.mu.RLock()
213-
wasGood := s.receivedGood
214-
s.mu.RUnlock()
215211
err := s.getStream().RecvMsg(m)
216212
if err == nil || err == io.EOF {
217-
s.mu.Lock()
218-
s.receivedGood = true
219-
s.mu.Unlock()
220-
return false, err
221-
} else if wasGood {
222-
// previous RecvMsg in the stream succeeded, no retry logic should interfere
223213
return false, err
224214
}
225215
if isContextError(err) {

0 commit comments

Comments
 (0)