Repository navigation
test: Fix a flaky test_proxy_07_cache_control.py (seen on Windows CI). - #864
Closed
arturobernalg wants to merge 1 commit into
Closed
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
The cache entry for the first request is committed by the CACHE_SAVE filter on the EOS-only pass that follows the body, which can still be running server side for an instant after the client has already read the complete body. Two back-to-back requests with no delay can race this, making the second one miss the cache and hit the backend again. Give the commit room to land before relying on it, instead of asserting immediately after the first request returns. Reproduced locally (about 1 in 5 runs failing, on different parametrized cases each time, none of them involving a comma) and confirmed fixed (0 failures in 55 runs) before and after this change. Also harden the TCPFaker backend used by this test to close its socket with an orderly shutdown() instead of an abrupt close(), which removes one more way for a slow platform to see a reset instead of a clean end of response.
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.
The cache entry for the first request is committed by the CACHE_SAVE filter on the EOS-only pass that follows the body, which can still be running server side for an instant after the client has already read the complete body. Two back-to-back requests with no delay can race this, making the second one miss the cache and hit the backend again.
Give the commit room to land before relying on it, instead of asserting immediately after the first request returns. Reproduced locally (about 1 in 5 runs failing, on different parametrized cases each time, none of them involving a comma) and confirmed fixed (0 failures in 55 runs) before and after this change.
Also harden the TCPFaker backend used by this test to close its socket with an orderly shutdown() instead of an abrupt close(), which removes one more way for a slow platform to see a reset instead of a clean end of response.
Fixes the flaky test_proxy_07_002/003 cases in test_07_cache_control.py (added in #821), seen failing on Windows CI. Reproduced locally too, about 1 in 5 runs, on different Cache-Control cases each time, including ones with no comma at all, so it's unrelated to the comma-parsing fix in #821. Root cause: the second request can race the first one's CACHE_SAVE commit, which can still be running for a moment after the client already read the full response. Confirmed fixed, 0 failures in 55 local runs.
(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.