-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Content is read from 304 response #6970
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
Comments
If you have a few minutes could you put the reproduction in terms of this helper script? Just for ease of checking when someone gets to this. |
I thought it a little further and came to this conclusion: If an ETag request is sent, and there is a cache miss, the result will be taken from the 304 response (which is empty) I'll try to assemble a small example server. |
@chrahunt thanks for the note. I updated the description. |
It looks like the current repro (and maybe the actual issue) are hitting this condition - if we aren't able to get something from the cache while processing a 304 then it returns the response directly. Further, the cache that we're using (
This should be fixed by the proposed solution to remove usage of lockfile in the cache in #4766 in favor of safer filesystem operations. |
If it improves the situation, I fully support your changes in #6879. The retry mechanism would also be beneficial. |
Under the new scheme, a 304 would only lead to error like this if the cache entry was explicitly removed by something external to pip (since pip itself would not do it, and we would only get a 304 if we had a cache entry in the first place), but I take your point. We should be robust to something like that. One hint for anyone that wants to address this: we could check for the status code from the response here, but I don't think that there's a nice way to incorporate that result into our existing retry mechanism. |
@andrask, just merged the lockfile changes. If you are able to you may try with the latest master version and see if there's any improvement. |
The cache updates are now part of 19.3, so it should be easier to check. |
@chrahunt Thank you very much! I cannot check if the error is gone. We worked around the issue by not using the http cache at all. Let's hope it got better. |
Thanks for checking! I think that is expected. While the server did help a lot to uncover the underlying issue, it is not well-behaved since normally a 304 should only be returned in response to a request which included cache information. The fix for that would be what was discussed above, making this area in general more robust with respect to response handling. I think it's still worth checking in your original environment if you're able to - at least it would help identify if the cause of the original issue was the race condition described here. |
I found a job that still uses the 'old mode' with http cache. The last three builds from Oct 25 to Oct 28 have installed the 19.3.x version and the issue seems to not have occurred. I guess it endorses that the new cache solution probably works much better. |
Uh oh!
There was an error while loading. Please reload this page.
Environment
Pypi server: local Artifactory
Highly concurrent tox/pip sessions.
Description
pip receives a 304 response and consumes the response as if it were valid data.
The log shows that the 304 response with size 0 is received.
Then the execution goes on to download the content and the error is raised when the installation is attempted. The error is always something like:
The erroneous SHA value of e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 indicates NULL content.
The error is sporadic and random but due to the sheer number of pip sessions, the result is a very high error rate.
Expected behavior
Normally, the log messages should show that the cache was used:
In the erroneous case, the messages are:
The expected behavior is that on 304 cache miss (that can obviously happen for some reason) the package is still downloaded and the cache is updated.
How to Reproduce
Given cachemiss_server.py
Run it with
python2 cachemiss_server.py
Then run pip to see the error:
pip install -i http://localhost:8888 certifi -v
The text was updated successfully, but these errors were encountered: