Skip to content
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

Merged
merged 1 commit into from
Aug 17, 2021
Merged

Caching: Fix race #1259

merged 1 commit into from
Aug 17, 2021

Conversation

eloycoto
Copy link
Contributor

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.
  6. request go to the API, and fails
  7. Authrep, cache for $KEY is deleted.

Fix THREESCALE-4464

Signed-off-by: Eloy Coto eloy.coto@acalustra.com

@eloycoto eloycoto requested a review from a team as a code owner February 12, 2021 12:40
@eloycoto eloycoto force-pushed the THREESCALE-4464b branch 2 times, most recently from 1292bbf to 79f07b6 Compare February 12, 2021 14:39
@@ -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
Copy link
Contributor

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"

@eloycoto eloycoto force-pushed the THREESCALE-4464b branch 2 times, most recently from 20a6a46 to b7ee759 Compare August 17, 2021 13:41
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>
Copy link
Contributor

@unleashed unleashed left a 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.

@eloycoto
Copy link
Contributor Author

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

@eloycoto eloycoto merged commit f35033e into master Aug 17, 2021
@eguzki eguzki deleted the THREESCALE-4464b branch August 17, 2022 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants