-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
pex throws a resolution error when using cache, succeeds otherwise #178
Comments
Some of the research here is relevant: pantsbuild/pants#2533 |
I've been hitting this with our pants setup as well. This results in a error from pants/pex, which looks like it could be solved: |
@arnib do you have any data or a repro you can share that indicates these issues are related? afaict, #178 only happens when one of the deps is completely unpinned - however in your case it appears boto is pinned somewhere ( fwiw:
|
Hey @kwlzn, thanks for checking this out. However the exception message still looks like something that should be resolvable. |
related to pantsbuild/pants#3527 |
+1 Would like to see this fixed as well. We're currently seeing random pants failures due to this. 1.1.11 fails as well.
|
So I dove into ze code and this is a multilayered problem. The trivial issue that causes this test to fail on the second go-around is because we're not passing --cache-ttl in the test. This works:
The reason it works with cache-ttl is because in https://github.com/pantsbuild/pex/blob/master/pex/resolver.py#L249 it resolves the packages found in the cache for the unbounded thrift resolvable if cache-ttl is set. Note that in https://github.com/pantsbuild/pex/blob/master/pex/resolver.py#L246 if the resolvable is exact, i.e. thrift==0.9.1 and it finds it in the cache, it always uses the cache. So, if cache-ttl is unset, for the unbounded So, in the case of --cache-ttl being unset, you can either:
However, I still think we have an identity crisis. Ultimately, I think it's a problem that this:
Is not considered the same as this:
Potential Solutions:
The problem with this approach is that it's now order dependent, the set intersection can return the remote SourcePackage or the local SourcePackage depending upon which side of the intersection you're on.
Ultimately this bites us in pants land, we have no control over transitive 3rdparty dependencies and are often bit at build time by this which creates non-deterministic builds. We could disable cache but that would slow our build times unacceptably. In the meantime I'm going to probably go for option 1, patch our pex with it in our cheeseshop and have it run on our build environment for a time to test it out. |
Actually, I ran into another edge case, this happens when an unbounded or inexact requirement in a resolvable is passed and --cache-ttl is used. In this case, if the cached version fits within the bounds of the resolvable requirement, and is less than ttl, only the cached version is returned. But if another resolvable has a requirement that doesn't match that cached version, then it fails. For example:
In this case, the first pex run pulls down thrift==0.9.0 into the cache. On the second run, it finds the unbounded dependency and pulls the thrift==0.9.0 from cache. It then finds the exact dependency for 0.9.1, grabs that from pypi, but since the first resolvable only pulls from cache, the intersection results in an empty set and Unsatisfiable is raised. This patch addresses that case by returning both the cached version found and the pypi results. In fact, this patch should mean we don't need to deal with package identity at all.
This doesn't solve the case where --cache-ttl is not used, but I think as far as pants goes, it passes a cache-ttl by default so this shouldn't affect it. I'll add some unit tests after further testing in our build environment and submit a PR soon. |
Ref: pex-tool#178 The error is as follows: 1. Two resolvables, one pinned, the other not. 2. First pex run with clean cache works. 3. Change the pinned version. 4. Second pex run fails with Unsatisfiable. The problem is that the non-pinned resolvable locates the cached dep and only returns it. Since that version doesn't match the pinned version, we fail. This fixes that behavior by returning both the cached version and all uncached pypi packages for unpinned resolvables. We change the pinned version to test the use case where you have a cached version of a dep and then you transitively pull in another requirement that either has a tighter bound or a pin on a version not found in the cache.
Ref: pex-tool#178 The error is as follows: 1. Two resolvables, one pinned, the other not. 2. First pex run with clean cache works. 3. Change the pinned version. 4. Second pex run fails with Unsatisfiable. The problem is that the non-pinned resolvable locates the cached dep and only returns it. Since that version doesn't match the pinned version, we fail. This fixes that behavior by returning both the cached version and all uncached pypi packages for unpinned resolvables. We change the pinned version to test the use case where you have a cached version of a dep and then you transitively pull in another requirement that either has a tighter bound or a pin on a version not found in the cache.
hmm, I still seem to be hitting this after the fix in #362:
|
Yah, 731d124 fixes a related problem where --cache-ttl is set and still raises Unsatisfiable. If there's no --cache-ttl then you can still hit this because it returns 3.2.1 from cache because it's exact and then searches pypi for the unbounded and takes the latest and those don't match in the |
Actually, now that I think about it, there is still the problem where you pass --cache-ttl, have an exact resolvable, an inexact resolvable and an expired cache. Probably exact resolvables shouldn't return from cache either if the cache has expired. But by default cache-ttl is set to None. |
makes sense - was mainly just highlighting my bad assumption that the core repro in this issue was repaired by #362. and fwiw, I have pantsbuild/pants#4277 out to consume this change in pants. |
Cool, I'll work on a fix and submit a new PR w/unit tests for this specific issue. |
* Add unit test and patch code to pass unit test Bug description: 1. Exact resolvable and inexact resolvable 2. First run completes, pushes exact resolvable into cache 3. Second run fails with Unsatisfiable Reproduce: $ pex psutil psutil==3.2.1 -o test.pex $ pex psutil psutil==3.2.1 -o test.pex Could not satisfy all requirements for psutil: psutil, psutil==3.2.1 The bug manifest itself in pex-tool#178 because by default --cache-ttl is set to None. This doesn't change those semantics. The default is still None, so we simply don't return an exact resolvable found in cache if the --cache-ttl isn't set. Doing so also fixes another bug where --cache-ttl is set, there is an exact resolvable found in cache, but it is expired. It should be noted that this patch could affect the performance of default pex runs which specify an exact resolvable but don't set --cache-ttl.
* Fix bug in cached dependency resolution with exact resolvable * Add unit test and patch code to pass unit test Bug description: 1. Exact resolvable and inexact resolvable 2. First run completes, pushes exact resolvable into cache 3. Second run fails with Unsatisfiable Reproduce: $ pex psutil psutil==3.2.1 -o test.pex $ pex psutil psutil==3.2.1 -o test.pex Could not satisfy all requirements for psutil: psutil, psutil==3.2.1 The bug manifest itself in #178 because by default --cache-ttl is set to None. This doesn't change those semantics. The default is still None, so we simply don't return an exact resolvable found in cache if the --cache-ttl isn't set. Doing so also fixes another bug where --cache-ttl is set, there is an exact resolvable found in cache, but it is expired. It should be noted that this patch could affect the performance of default pex runs which specify an exact resolvable but don't set --cache-ttl. * fixup! Fix bug in cached dependency resolution with exact resolvable * fixup! Fix bug in cached dependency resolution with exact resolvable
verified this is fixed in master. huge shoutout to @butlern for the bugfix(es)! |
Fixes pex-tool#178 The error is as follows: Two resolvables, one pinned, the other not. First pex run with clean cache works. Change the pinned version. Second pex run fails with Unsatisfiable. The problem is that the non-pinned resolvable locates the cached dep and only returns it. Since that version doesn't match the pinned version, we fail. This fixes that behavior by returning both the cached version and all uncached pypi packages for unpinned resolvables. We change the pinned version to test the use case where you have a cached version of a dep and then you transitively pull in another requirement that either has a tighter bound or a pin on a version not found in the cache.
…ol#365) * Fix bug in cached dependency resolution with exact resolvable * Add unit test and patch code to pass unit test Bug description: 1. Exact resolvable and inexact resolvable 2. First run completes, pushes exact resolvable into cache 3. Second run fails with Unsatisfiable Reproduce: $ pex psutil psutil==3.2.1 -o test.pex $ pex psutil psutil==3.2.1 -o test.pex Could not satisfy all requirements for psutil: psutil, psutil==3.2.1 The bug manifest itself in pex-tool#178 because by default --cache-ttl is set to None. This doesn't change those semantics. The default is still None, so we simply don't return an exact resolvable found in cache if the --cache-ttl isn't set. Doing so also fixes another bug where --cache-ttl is set, there is an exact resolvable found in cache, but it is expired. It should be noted that this patch could affect the performance of default pex runs which specify an exact resolvable but don't set --cache-ttl. * fixup! Fix bug in cached dependency resolution with exact resolvable * fixup! Fix bug in cached dependency resolution with exact resolvable
when passing two requirements of the form (unpinned, pinned) for the same package (e.g. 'thrift thrift==0.9.1'), pex has different behavior in resolution depending on whether or not the cache is used. this also manifests in consumers of pex (i.e. pants) when dependencies land in a similar order.
repro:
this also repros under 1.1.0 and for different packages:
and is also affected by ordering:
The text was updated successfully, but these errors were encountered: