Alanxtl commented on code in PR #3832:
URL: https://github.com/apache/dubbo-go/pull/3832#discussion_r4594410231


##########
remoting/getty/getty_client.go:
##########
@@ -267,6 +267,11 @@ func (c *Client) RequestContext(ctx context.Context, 
request *remoting.Request,
        case <-response.Done:
                err = response.Err
        case <-ctx.Done():
+               // Drop the pending waiter, but keep the shared session. Caller
+               // cancellation is not a transport failure; a later request may
+               // reuse this connection. The read-timeout branch still closes
+               // the session because that path can no longer trust it.
+               
remoting.RemovePendingResponse(remoting.SequenceType(request.ID))

Review Comment:
   直接使用 `getty.Client.RequestContext` 时,如果客户端先取消请求、服务端稍后才返回,新增代码会先删除 pending 
response。迟到响应随后进入 Response.Handle,因找不到 pending 被记录为 
ERROR。取消在这种场景下是正常行为,但大量取消会刷错误日志和堆栈,干扰告警。
   
   还有一个**既有边界**:如果底层调用方注册 pending 后传入一个已经取消的 context,`RequestContext` 
会在进入新增分支前返回,pending 仍需调用方清理。上层 `ExchangeClient` 的清理逻辑不受此影响。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to