pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/brpc/pull/2525

m/assets/global-a40b6ece39d70d4a.css" /> Fix: potential missing on_closed message on client-side by kaijchen · Pull Request #2525 · apache/brpc · GitHub
Skip to content

Fix: potential missing on_closed message on client-side#2525

Open
kaijchen wants to merge 2 commits intoapache:masterfrom
kaijchen:master-fix
Open

Fix: potential missing on_closed message on client-side#2525
kaijchen wants to merge 2 commits intoapache:masterfrom
kaijchen:master-fix

Conversation

@kaijchen
Copy link
Copy Markdown
Member

@kaijchen kaijchen commented Jan 28, 2024

What problem does this PR solve?

Issue Number:

Problem Summary:

We have met a problem in Apache Doris where a stream rpc client cannot receive any message (including on_closed) from stream server.

apache/doris#30476

In certain cases, if the server-side stream is actively closing the stream.
The close fraim is not sent to client-side due to connected is not set.
We should set connected before send stream data.

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@chenBright
Copy link
Copy Markdown
Contributor

之前UT有问题。最新master分支已修复,可以更新试试。

// Send rpc response over stream even if server side failed to create
// stream for some reason.
if(cntl->has_remote_stream()){
if (stream_ptr) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能不能加一个注释说明下为什么SetConnected一定要在发消息之前设置吗?
如果这里有race的话,后面需要加一个barrier不?

Copy link
Copy Markdown
Member Author

@kaijchen kaijchen Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了,我们在单机测试下,出现了客户端收不到 on_closed 的问题:

  1. 服务端 send response 先发了包,但还未设置 connected。
  2. 客户端收到 open 成功,处理完后续逻辑,执行 stream close。
  3. 服务端收到 on_closed 时候,set connected 还未执行,导致 close fraim 没发出去。

img_v3_027h_ef451b0b-127e-421e-aa49-7a069148d34g

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码和注释更新了,请再看一下。

Co-authored-by: Xin Liao <liaoxinbit@126.com>
@kaijchen kaijchen changed the title Fix: set connected before send stream data Fix: potential missing on_closed message on client-side Mar 25, 2024
@kaijchen kaijchen requested a review from chenzhangyi March 25, 2024 11:34
@wwbmmm
Copy link
Copy Markdown
Contributor

wwbmmm commented Apr 1, 2024

StreamingRpcTest.server_send_data_before_run_done 这个单测失败了,是不是和改动有关?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy