Commit 2c4a883
committed
Avoid a race-condition on ETag validation.
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 :(1 parent a4b13be commit 2c4a883
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| |||
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
482 | | - | |
| 484 | + | |
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
| |||
0 commit comments