Skip to content

none stop retry when upstream peer close socket #693

@GhostZCH

Description

@GhostZCH

We fond a problem when use balance by lua module. The process is like bellow:

  1. Client visit a right url and ngx setup a keep alive connection to upstream peer success;
  2. Another client visit a wrong url and ngx send the request to the the upstream peer;
  3. The upstream peer find the request is a wrong url and close the connection immediately;
  4. Then, ngx while try setup new connections and sent the wrong request repeatitively until we reload ngx.

I find you reduse u->peer.tries in ngx_http_lua_balancer_free_peer
but ngx_http_upstream_next do u->peer.tries++. That makes me confused.

ngx_http_upstream_next:
if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR
    && (!u->request_sent || !r->request_body_no_buffering))
{
    status = 0;

    /* TODO: inform balancer instead */

    u->peer.tries++;

} else {

ngx_http_lua_balancer_free_peer:
if (bp->sockaddr && bp->socklen) {
    bp->last_peer_state = (int) state;

    if (pc->tries) {
        pc->tries--;
    }

    return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions