Skip to content

resty-lock inoperative in init_worker_by_lua_file #18

@chopper-poet

Description

@chopper-poet

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'

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