openresty / openresty/lua-nginx-module
Improvement suggestion: locking shdict keys
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
As you might know: Session management without a locking mechanism can lead to data-corruption as parallel requests will cause race-conditions. Please add this feature:
res=shdict:lock_key(key);
res=shdict:unlock_key(key);
And for performance-reasons a combined command for the most obvious tasks:
data, res=shdict:lock_key_and_get(key);
res=shdict:set_and_unlock_key(key, data);
and do an auto-unlock for all keys still being locked for that request when the Lua-script ends.
Maybe one could also allow a security-auto-unlock after 30 seconds.
You just put a new int into your shdict node-structure and when it is 0 it is unlocked.
When it contains a timestamp > 0 it is locked and when now-timestamp>30 then ignore this previous lock when trying to lock it.
Locktime-limit can be set as second parameter in lock_key(key, lock_timeout) and lock_key_and_get(key, lock_timeout).
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 by locating the shdict node structure and the entry points for shdict operations and Lua-script request cleanup. Define the locking, timeout, combined-operation, and automatic-unlock behavior, then verify the feature across parallel requests and expired locks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100