openresty / openresty/lua-resty-lock
resty-lock inoperative in init_worker_by_lua_file
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 323
- Forks
- 81
- Avg merge
- 7h 41m
- Merged PRs (30d)
- 2
Description
hi,agentzh
I used lock:lock on init_worker_by_lua_file,but inoperative.
here is my code
`local resty_lock = require "resty.lock"
local lockOpts = {["exptime"]="5",["timeout"]="0"}
local lock, err = resty_lock:new("MY_LOCKS",lockOpts)
if not lock then
ngx.log(ngx.ERR,"failed to create lock:"..tostring(err))
return
end
local elapsed, err = lock:lock('lock_key')
if not elapsed then
ngx.log(ngx.DEBUG,"failed to acquire the lock: "..tostring(err))
return
else
ngx.log(ngx.DEBUG,"get lock success")
return
end
)`
My nginx has 4 workers and i set timeout=0 for get lock operation,but still display 4 'get lock success'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported init_worker_by_lua_file entry point and the resty.lock:new and lock calls shown in the issue. Reproduce with four nginx workers and timeout=0, then inspect the resty.lock behavior and shared-memory configuration; done means determining why multiple workers report success and documenting or correcting the behavior.
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