openresty / openresty/lua-resty-core

After upgrading lua resty core to 0.1.17 for every request seeing some warnings related to race condition

Open
#299 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
853
Forks
286
Avg merge
35m
Merged PRs (30d)
1

Description

Getting below error:
[warn] 5352#5352: *290 [lua] _G write guard:12: __newindex(): writing a global lua variable ('message') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables

Sample code
local M = {}
local function checkAuth()

-- logic to get auth value
if type(check[auth.type]) == "function" then
ok, message = checkauth.type
if ok then
authorized= true
break
end
end
-- logic
end
M.checkAuth=checkAuth
return M

Corresponding Nginx version : nginx-plus-20-1.el7.ngx.x86_64
Before upgrading Nginx version and lua-resty-core I didn't see any such errors

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 _G write guard warning and the sample checkAuth function, focusing on the undeclared message assignment and the nginx-plus-20/lua-resty-core upgrade context. Reproduce the warning with the sample request flow and compare behavior before and after the upgrade. Done means establishing whether the warning is expected for this code and identifying the affected change or documentation needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.