客户端流导致的channel复用没有初始话

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
grpc, php

Research direction

Start with GrpcClient.php recv, runReceiveCoroutine, and closeRecv, then trace how channels are returned to and obtained from the channel pool. Reproduce the client-streaming SendAndClose sequence described in the issue and inspect whether unread close data remains in a reused channel. Done means a subsequent request cannot read stale data from the previous stream.

Written by the indexing model from the issue text.

Description

对于一个客户端流来说 服务端调用了SendAndClose

Image

客户端函数runReceiveCoroutine 对这个流进行revc 实际上进行了3次
第一次是正常的数据返回 但是客户端流只允许调用一次recv 就不会触发到GrpcClientrecv中的 if (($response === false && $channel->errCode === SWOOLE_CHANNEL_TIMEOUT) || ($response instanceof Response && ! $response->pipeline)) {

Image

第二次是关闭

第三次response 为false 走到了如下流程:

Image

closeRecv函数在进行channel 回收的时候没有判断channel里面是否有数据 直接进行了回收

下一个请求获取从channel池里面获取channel 获取到旧的channel 此时channel里面的数据 是第一次请求获取响应中的第二个响应及关闭响应 导致GrpcClient.php中recv进行读取的时候 读到的数据是关闭请求 之后才会触发重置和回收channal

Image
我尝试进行多读一次 和 在closeRecv进行channel->pop() 是可以解决这个问题

Image

Image

不知道是不是我的使用方式有什么问题?

Dominant language
PHP
Stars
3
Forks
6
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hyperf/grpc-client

All issues in hyperf/grpc-client

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.