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

Write separate statefiles per prefix. #6855

Merged
merged 8 commits into from
Sep 7, 2019

Conversation

chrahunt
Copy link
Member

@chrahunt chrahunt commented Aug 10, 2019

Previously, we kept selfcheck info for all pip instances in the same file.

Now, we use a separate file per pip instance, simplifying the process of recording updated state.

Also added several tests that are a little less intrusive into the selfcheck implementation details.

Makes progress on #6954.

@chrahunt chrahunt added skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code labels Aug 10, 2019
@chrahunt chrahunt force-pushed the refactor/separate-statefile-states branch from 3800e01 to 204306d Compare August 10, 2019 23:21
Copy link
Member

@cjerdonek cjerdonek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple comments.

src/pip/_internal/utils/outdated.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/outdated.py Outdated Show resolved Hide resolved
@chrahunt
Copy link
Member Author

Unrelated failure on Appveyor and it doesn't appear to have "Rebuild" buttons like Travis, so closing/reopening.

@chrahunt chrahunt closed this Aug 11, 2019
@chrahunt chrahunt reopened this Aug 11, 2019
@pradyunsg
Copy link
Member

Unrelated failure on Appveyor and it doesn't appear to have "Rebuild" buttons like Travis, so closing/reopening.

Yea, AppVeyor <-> GitHub permissions is weird. I think one needs to be an Admin on AppVeyor at the organization level to do that.

Aside, if you see an unrelated failure from our test suite (not the CI's bootstrapping/setup) please file an issue -- ideally our tests would be reasonably resilient to the occasional network issues, system-specific configuration and cosmic-ray-induced bit flips. Okay, maybe not that last one.

@chrahunt
Copy link
Member Author

👍

@cjerdonek, any other comments or concerns?

@chrahunt chrahunt force-pushed the refactor/separate-statefile-states branch from ece6aac to 7d1034e Compare August 14, 2019 01:45
@chrahunt chrahunt force-pushed the refactor/separate-statefile-states branch from 7d1034e to c91af0d Compare August 14, 2019 01:50
@chrahunt
Copy link
Member Author

Refactored and split into separate commits so it should hopefully be easier to review. Please forgive my mess before. 🙏

@cjerdonek
Copy link
Member

@cjerdonek, any other comments or concerns?

I haven't read the thread about the underlying rationale, but on the surface the code and change looks okay to me.

My only question / concern is around the length of the filename (79 characters). I'm wondering if that could ever cause problems. It doesn't strike me as something that needs cryptographic strength, but again, I haven't read the thread to know for sure.

@chrahunt
Copy link
Member Author

chrahunt commented Aug 14, 2019

The only property we need is being able to map to the same file, unique per prefix, independently on each invocation of the same pip. A cryptographically secure hash requires less consideration than one that may be considered broken or insecure, so it's a reasonable default IMO.

I could switch to sha224 as used in cache control, which would bring our path length to 70 (comparable to the 66 used for one of our http cache entries, which are kept in the same directory).

@chrahunt
Copy link
Member Author

I have switched to sha224, moved the files to a subdirectory, and dropped the file extension. Now the file path length should be the same as for any of our HTTP cache files.

@chrahunt
Copy link
Member Author

@cjerdonek, in case there are any concerns I have submitted #6879 so it is more clear where this is going and how it is related to #4766. Specifically, once we simplify our usage of the selfcheck state file from "read, merge, write" to just "write" then we do not need file locking and can just overwrite the file.

@cjerdonek
Copy link
Member

@chrahunt I don't have any concerns... I trust and am sure the underlying idea is sound. It's just that I haven't had time to look at it. I was kind of hoping that the people participating in the #4766 discussion would, since it's not a discussion I really read / participated in.

@cjerdonek
Copy link
Member

I appreciate the thought and additional write-up though! If I can get to it, it will help me get up to speed on what you're planning.

@chrahunt
Copy link
Member Author

If it's okay, we can treat this PR independently of the underlying lockfile issue (similar to #6845). I think it's only necessary to consider it in the context of the larger issue if there's not enough justification for these changes on their own.

@chrahunt
Copy link
Member Author

The discussion on #6879 indicates that the general approach is OK, and it is just a matter of deciding where to put the new utility methods. We will need the changes from this PR regardless of the outcome of that decision.

@chrahunt
Copy link
Member Author

chrahunt commented Sep 7, 2019

OK to merge?

@pradyunsg pradyunsg merged commit 8b2e1c8 into pypa:master Sep 7, 2019
@pradyunsg
Copy link
Member

@chrahunt yep!

@chrahunt chrahunt deleted the refactor/separate-statefile-states branch September 7, 2019 04:08
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants