-
Notifications
You must be signed in to change notification settings - Fork 171
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
Caching: Fix race #1259
Caching: Fix race #1259
Conversation
1292bbf
to
79f07b6
Compare
@@ -101,17 +101,29 @@ local function handler(config) | |||
return res | |||
end | |||
|
|||
local function is_disabled(config) | |||
if config.caching_type and config.caching_type == "none" then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified:
return config.caching_type and config.caching_type == "none"
20a6a46
to
b7ee759
Compare
When caching is disabled with none, the cache key can be in there, and a race condition can be happend with this. To test this: 1) Strict caching mode 2) Made a request, 200 OK cache.set("$KEY", 200) 3) Update config to none 4) apicast/proxy:authorize -> cache.get($KEY) is 200 5) request go to the API 6) Authrep, cache for $KEY is deleted. Next request will return 403. Fixed behaviour: 1) Strict caching mode 2) Made a request, 200 OK cache.set("$KEY", 200) 3) Update config to none 4) apicast/proxy:authorize -> cache.get($KEY) is 200 5) cache_is_disabled = true -> execute backend call. 5) request go to the API, and fails 6) Authrep, cache for $KEY is deleted. Fix THREESCALE-4464 Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
b7ee759
to
85c0f78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok if the expectation is that caching will be enabled by default and only disabled when explicitly set to none. Is this assumption correct? Other than that, LGTM.
YUP |
When caching is disabled with none, the cache key can be in there, and a
race condition can be happend with this.
To test this:
Next request will return 403.
Fixed behaviour:
Fix THREESCALE-4464
Signed-off-by: Eloy Coto eloy.coto@acalustra.com