Avoid a race-condition on ETag validation.#425
Open
JulienPalard wants to merge 1 commit into
Open
Conversation
Author
|
As a nice side effect this save one disk read in case the server answers a 304 to a validation request. But I'm not proud of my edit of So if someone with a better theory of the project than me has a better idea, don't hesitate. After all that's just the first time I read |
For example, in case multiple Python versions are using the same cache and some are <3.14 and other >=3.14, the Accept-Encoding header will vary between `gzip, deflate` and `gzip, deflate, zstd`. If two processes, say p1 (with zstd support) and p2 (without zstd support) do two requests to the same URL, with an already cached result (for the without zstd support request) it could lead to the following race condition: - P1 reads the cache, fails because Accept-Encoding does not match - P1 sends a normal request - P2 reads the cache, succeeds, but needs validation - P2 sends a validation request (with If-None-Match) - P1 receives a response for its Accept-Encoding: gzip, deflate, zstd - P1 updates the cache with it - P1 returns the 200 OK to the user - P2 receives a 304 Not Modified response - P2 wants to return from the cache, but fails to read it (wrong Accept-Encoding!) - P2 fallbacks to returning a 304 Not Modified response to the user :(
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For example, in case multiple Python versions are using the same cache and some are <3.14 and other >=3.14, the Accept-Encoding header will vary between
gzip, deflateandgzip, deflate, zstd.If two processes, say p1 (with zstd support) and p2 (without zstd support) do two requests to the same URL, with an already cached result (for the without zstd support request) it could lead to the following race condition:
Closes #424