-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use lock in limit req #48
Conversation
Signed-off-by: Hiroaki Nakamura <[email protected]>
Signed-off-by: Hiroaki Nakamura <[email protected]>
Signed-off-by: Hiroaki Nakamura <[email protected]>
Signed-off-by: Hiroaki Nakamura <[email protected]>
Signed-off-by: Hiroaki Nakamura <[email protected]>
@hnakamur |
Thanks, another sharedict API I suppose the syntax like below
Is this correct? |
update_func can
if |
@hnakamur to avoid the race completely, we may need another API, like |
Thanks, but in the case of
So I think But how about adding a method named
In this way, just one method call is needed, and locking the shared dict and looking up the node in the tree of the shared dict is executed just once, not twice, so I think it is more performant. |
@hnakamur for your |
Thanks for your comment. I've refined the openresty/lua-nginx-module@master...hnakamur:add_shdict_update If it is on the right track, I will add the FFI version of update method and add it also to stream-lua-nginx-module and openresty/lua-resty-core: New FFI-based API for lua-nginx-module. |
Ah, I see, if you access the same dictionary in the lua function called from the Then I throw away the |
But I think it is enough to tell that don't access the shared dictionary in If What do you think? |
I've added an explanation of deadlock to the CAUTION section. It may not be safe, but I think it's easy to spot when you actually write code to cause dead lock, as it does not work as expected and that is very easy to notice. I think that the race condition caused by successive calls of |
I modified master...hnakamur:fix_race_condition_with_shdict_update_method |
I also made openresty/lua-nginx-module@master...hnakamur:add_shdict_set_when master...hnakamur:fix_race_condition_with_shdict_update_method |
I wrote |
And after re-reading FFI Semantics, now I think that I should avoid |
I made another pull request |
First of all, thanks for sharing a nice library!
I noticed a FIXME comment lib/resty/limit/req.lua and this pull request is my attempt to fix it.
Could you review this?
Thanks!