openresty / openresty/lua-nginx-module

Lua's fake requests remain uncleaned in successful cases

Open
#1,098 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

Recently I have had difficulties with such error:
2017/06/07 04:10:42 [alert] 4579#0: *35005 1024 worker_connections are not enough while connecting to upstream

What I found out:
If I'm right, the connections do not close in successful cases in all ngx_http_lua_ssl*_ modules.

Usually connections are created:

fc = ngx_http_lua_create_fake_connection(NULL);

However, the cleaning function is only called in unsuccessful cases:

failed:

    if (r && r->pool) {
        ngx_http_lua_free_fake_request(r);
    }

    if (fc) {
        ngx_http_lua_close_fake_connection(fc);
    }

In successful cases, a handler just return a value:

    if (rc >= NGX_OK || rc == NGX_ERROR) {
        cctx->done = 1;
        ...
        ngx_log_debug2(...);
        ...
        return <something "good">;
    }

Maybe I don't understand something in the architecture, but inserting the cleanup code before returning the "good" value helped me.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the ngx_http_lua_ssl_* modules and compare their successful return paths with the shown failed path. Reproduce or verify whether fake requests and connections remain open after successful cases, then confirm that all relevant paths clean them up without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.