Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tengine + xquic 上传文件超过 200K 后出现文件内容损坏 #1937

Open
fbwfbi opened this issue May 31, 2024 · 4 comments
Open

tengine + xquic 上传文件超过 200K 后出现文件内容损坏 #1937

fbwfbi opened this issue May 31, 2024 · 4 comments
Assignees

Comments

@fbwfbi
Copy link

fbwfbi commented May 31, 2024

Ⅰ. Issue Description

tengine + xquic 上传文件超过 200K 后出现文件内容不一致

Ⅱ. Describe what happened

使用 tengine + xquic 配置文件上传服务,向后端的 http 服务上传文件,当上传文件大小超过 200K 后,出现文件内容有损;

确认后端 http 文件上传服务无问题

Ⅲ. Describe what you expected to happen

定位原因,修复该 Bug,在 client_max_body_size 限制内,保证文件内容上传完整

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. 配置 xquic 监听器;
  2. proxy_pass 到后端 http 服务器;
  3. 通过支持 http3 的 curl 版本,或其他 quic 客户端上传文件,文件大小超过 200k 后,会出现文件内容不一致;使用 300k 测试 10000 次,出现 7 次 文件内容哈希值不一致;当文件大小为 50M 时,每次上传文件的内容都不一致。

Ⅴ. Anything else we need to know?

跟文件上传有关的配置参数如下

    client_max_body_size  50g;
    
    large_client_header_buffers  4 32k;
    proxy_request_buffering  off;

    client_body_buffer_size 64k;
    client_body_postpone_size 64k;
    client_body_buffers 16 8k;

    proxy_buffering  off;
    proxy_buffer_size  16k;
    proxy_buffers   8  8k;

Ⅵ. Environment:

tengine:3.1.0
xquic: 1.7.2

@fbwfbi
Copy link
Author

fbwfbi commented May 31, 2024

66c751472926d6be1d99a085be8bae70
87a4f4524d0027fd00255a34b718d518
9a1267ded891b073fb2f9f1de3878da1

@fbwfbi
Copy link
Author

fbwfbi commented Jun 5, 2024

Workaround

开启 proxy_request_buffering, 配置 client_body_buffer_size 大于实际上传文件的 body 请求大小,即可上传完整。

@fbwfbi
Copy link
Author

fbwfbi commented Jun 7, 2024

@lianglli 这个问题 tengine 目前团队的核心人员有人跟进吗? 如果开启 proxy_request_buffering 缓存整个 request_body 的话,目前 xquic 模块只能将 body 全部 in_memory 到内存 buffer 里面,即必须要求 client_body_buffer_size > len(client_reqeuest_body) 。经测试,目前也不能使用临时缓冲文件,即设置 client_body_in_file_only on 无效。

这个问题其实挺严重的,如果只能采用 ”边缓冲边上传” 的模式,必须解决出现文件内容损坏的问题。看了一下源码,是 r->request_body->buf 的边界处理问题,还涉及到 quic/http3 的流控的问题(http3 无法像 http2 那样,通过WINDOW_UPDATE 帧直接通告接收窗口大小, 只能在 quic 层面去调整)。如果没人跟进的话,可以把这个问题 assign 给我。

@fbwfbi fbwfbi changed the title tengine + xquic 上传文件超过 200K 后出现文件内容不一致 tengine + xquic 上传文件超过 200K 后出现文件内容损坏 Jun 7, 2024
@lianglli
Copy link
Member

这是一个已知的内部问题;你提及的workaround是正确的,针对H3协议的上传文件和大报文的场景,需要禁用流式传输,缓存收包完成后,再向后端upstream转发。

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

No branches or pull requests

2 participants