proxy_next_upstream失效的问题

253 views
Skip to first unread message

肖贝贝

unread,
Sep 22, 2016, 11:27:08 AM9/22/16
to openresty
hi, all:

我们在线上使用proxy_next_upstream来对后端失效进行容错, 配置是:

proxy_next_upstream error timeout http_502 invalid_header;

但是在部分情况下发现请求不能被重试到下一个后端, 表现是:

1. 在不能重试时, 通过 ngx.var.upstream_status 拿到的状态码为502

2. 在不能重试时, error log 打印出两种信息:

recv() failed (104: Connection reset by peer) while reading response header from upstream

或者是

upstream prematurely closed connection while reading response header from upstream



看起来是在读取 header 的时候遇到了错误, 但这时应该能命中invalid_header走重试才对, 但实际上请求到这里就结束了, 不再继续下一步



另一个问题, 关于 balancer 模块, 在后端明确返回502的情况下, balancer 模块的 get_last_failure 接口返回了 failed, 设计的原因是什么


@agentzh


thanks

肖贝贝

unread,
Sep 22, 2016, 11:31:44 AM9/22/16
to openresty
补充一下, 这个问题似乎出现在升级 openresty 之后, 之前的版本1.9.7在这种情况下可以进行重试, 升级到1.11.2后出现, 多谢

在 2016年9月22日星期四 UTC+8下午11:27:08,肖贝贝写道:

肖贝贝

unread,
Sep 22, 2016, 11:32:48 AM9/22/16
to openresty
再补充一下, 这时候 nginx 不仅返回了了502错误码, 而且打印出了502 的标准 html 页面

在 2016年9月22日星期四 UTC+8下午11:31:44,肖贝贝写道:

DeJiang Zhu

unread,
Sep 27, 2016, 7:23:37 AM9/27/16
to open...@googlegroups.com
Hello

你确定你的场景里还有足够的重试次数?
能否搞出来一个稳定可复现的最小化用例?

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

肖贝贝

unread,
Sep 27, 2016, 10:49:33 PM9/27/16
to openresty
嗯, 是的, 重试次数足够

在 github 发了帖子, 


与新增的proxy_next_upstream non-idempotent 关系比较大, 是新增的特性, 不是 bug, 看日志 HEAD 请求也重试了, 只有 POST 没有重试

thanks

在 2016年9月27日星期二 UTC+8下午7:23:37,doujiang写道:
Hello

你确定你的场景里还有足够的重试次数?
能否搞出来一个稳定可复现的最小化用例?

在 2016年9月22日 下午11:27,肖贝贝 <xbs...@gmail.com>写道:
hi, all:

我们在线上使用proxy_next_upstream来对后端失效进行容错, 配置是:

proxy_next_upstream error timeout http_502 invalid_header;

但是在部分情况下发现请求不能被重试到下一个后端, 表现是:

1. 在不能重试时, 通过 ngx.var.upstream_status 拿到的状态码为502

2. 在不能重试时, error log 打印出两种信息:

recv() failed (104: Connection reset by peer) while reading response header from upstream

或者是

upstream prematurely closed connection while reading response header from upstream



看起来是在读取 header 的时候遇到了错误, 但这时应该能命中invalid_header走重试才对, 但实际上请求到这里就结束了, 不再继续下一步



另一个问题, 关于 balancer 模块, 在后端明确返回502的情况下, balancer 模块的 get_last_failure 接口返回了 failed, 设计的原因是什么


@agentzh


thanks

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages