Opened 8 years ago

Closed 8 years ago

#1277 closed defect (wontfix)

u->peer.free in ngx_http_upstream_finalize_request

Reported by: yan.sheng.upai.com@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.11.x
Keywords: Cc:
uname -a:
nginx -V: 1.11.6

Description

upstream backend-test {

server 127.0.0.1:9001; return 502
server 127.0.0.1:9002;
return 502
server 127.0.0.1:9003; return 502

}

server {

listen 8000;
proxy_next_upstream error timeout http_502;
proxy_pass http://backend-test;

}

when curl http://127.0.0.1:8000,

ngx_http_upstream_free_round_robin_peer will enter three times,
first 127.0.0.1:9001 return 502, state NGX_PEER_FAILED
second 127.0.0.1:9002 return 502, state NGX_PEER_FAILED
but thrid 127.0.0.1:9003 return 502, state is zero,because of ngx_http_upstream_finalize_request:

if (u->peer.free && u->peer.sockaddr) {

u->peer.free(&u->peer, u->peer.data, 0); state always is zero
u->peer.sockaddr = NULL;

}

Change History (1)

comment:1 by Maxim Dounin, 8 years ago

Resolution: wontfix
Status: newclosed

The NGX_PEER_FAILED flag is only set when switching to the next upstream server as per the proxy_next_upstream directive. As nginx has no other servers to try in the third case, nginx simply returns a response it got from the last server, and doesn't try to mark it as failed.

Note: See TracTickets for help on using tickets.