openresty / openresty/luajit2

iterate over non-empty table got empty

Open
#181 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.4k
Forks
252
Avg merge
7d 11h
Merged PRs (30d)
3

Description

The original issue was reported in google group.

https://groups.google.com/g/openresty-en/c/4DXfmYSU7Jo/m/bUajTOB0AQAJ?utm_medium=email&utm_source=footer

i am testing my proxy server by new version of openresty (1.21.4), and i have a big problem
in load test
my nginx config just :worker 1;
and i have some code like this:

rewrite_by_lua_block {
    local t = {["1.2.3.4"] = { ["weight"] = 1}, ["4.5.6.7"] = { ["weight"] = 2}}
    ngx.ctx.t = t
}

balancer_by_lua_block{
    localt = ngx.ctx.t
    for key, value in pairs(t) do print(key) end -- output is empty
    for key, value in pairs(t) do print(key) end -- have output
}

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 with the linked Google Group report and reproduce the issue using the shown rewrite_by_lua_block and balancer_by_lua_block configuration. Compare both pairs iterations over ngx.ctx.t; done means the first iteration no longer produces an empty result or the behavior is clearly documented as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
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.