Skip to content

Commit

Permalink
online: print logs to identify early EOF for gRPC ServerStreaming
Browse files Browse the repository at this point in the history
  • Loading branch information
DMwangnima committed Feb 7, 2025
1 parent c5acf5e commit 0bc2464
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/remote/trans/nphttp2/grpc/http2_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ func (t *http2Server) handleData(f *grpcframe.DataFrame) {
return
}
if size > 0 {
s.isReceiveFromClient = true
if err := s.fc.onData(size); err != nil {
t.closeStream(s, true, http2.ErrCodeFlowControl, false)
return
Expand All @@ -570,6 +571,14 @@ func (t *http2Server) handleData(f *grpcframe.DataFrame) {
}
}
if f.Header().Flags.Has(http2.FlagDataEndStream) {
if !s.isReceiveFromClient {
md, ctxOK := metadata.FromIncomingContext(s.ctx)
if ctxOK {
klog.CtxInfof(s.ctx, "receive EOS flag directly, md: %+v", md)
} else {
klog.CtxInfof(s.ctx, "receive EOS flag directly")
}
}
// Received the end of stream from the client.
s.compareAndSwapState(streamActive, streamReadDone)
s.write(recvMsg{err: io.EOF})
Expand Down
2 changes: 2 additions & 0 deletions pkg/remote/trans/nphttp2/grpc/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ type Stream struct {
// contentSubtype is the content-subtype for requests.
// this must be lowercase or the behavior is undefined.
contentSubtype string

isReceiveFromClient bool // indicates whether receiving data from the client
}

// isHeaderSent is only valid on the server-side.
Expand Down

0 comments on commit 0bc2464

Please # to comment.