openresty / openresty/lua-nginx-module
set new key to ngx.shared.dict result in expired old key becoming nil
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
reproduce script (using resty-cli)
resty --shdict='dogs 1m' -e 'local dict = ngx.shared.dogs
dict:set("test004", 444, 5, 1)
dict:set("test005", 555, 5, 1)
dict:set("test001", 111, 5, 1)
dict:set("test002", 222, 5, 1)
dict:set("test003", 333, 5, 1)
print("---------get all key in 5s")
print("test001: ",dict:get_stale("test001"))
print("test002: ",dict:get_stale("test002"))
print("test003: ",dict:get_stale("test003"))
print("test004: ",dict:get_stale("test004"))
print("test005: ",dict:get_stale("test005"))
ngx.sleep(6)
print("--------sleep 6s, get all keys that already expired")
print("test001: ",dict:get_stale("test001"))
print("test002: ",dict:get_stale("test002"))
print("test003: ",dict:get_stale("test003"))
print("test004: ",dict:get_stale("test004"))
print("test005: ",dict:get_stale("test005"))
print("--------set a new key, then get all keys that already expired")
dict:set("test006", 666, 5, 1)
print("test001: ",dict:get_stale("test001"))
print("test002: ",dict:get_stale("test002"))
print("test003: ",dict:get_stale("test003"))
print("test004: ",dict:get_stale("test004"))
print("test005: ",dict:get_stale("test005"))
'
result
---------get all key in 5s
test001: 1111false
test002: 2221false
test003: 3331false
test004: 4441false
test005: 5551false
--------sleep 6s, get all keys that already expired
test001: 1111true
test002: 2221true
test003: 3331true
test004: 4441true
test005: 5551true
--------set a new key, then get all keys that already expired
test001:
test002:
test003: 3331true
test004: 4441true
test005: 5551true
As a result, I think the result should be that all key can get data, but now, “test001“ and ”test002” do not get data(nil), and these key are set after “test003”、“test004“、”test005”。
Any idea are welcome!
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
Run the supplied resty-cli reproduction against ngx.shared.dogs and compare get_stale results before and after setting test006. No source file or test is named; trace the ngx.shared.dict set and get_stale entry points, then verify that all five expired keys still return their stale values after the new key is inserted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100