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

Fix bug in cached dependency resolution with exact resolvable #365

Merged
merged 3 commits into from
Mar 7, 2017

Conversation

butlern
Copy link
Contributor

@butlern butlern commented Feb 27, 2017

  • 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.

@kwlzn this should fix #178 now, however, it changes the previous behavior by not returning an exact resolvable found in cache which might affect default performance. I was a little hesitant to set a default for --cache-ttl. Let me know if you think I should do that.

  * 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.
Copy link
Contributor

@kwlzn kwlzn left a comment

Choose a reason for hiding this comment

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

lgtm! tho I do think it would probably make sense to set a default cache ttl in pex/bin/pex.py to accompany this change. how does 1 hour (3600s) sound?

if self.__cache_ttl:
packages = self.filter_packages_by_ttl(packages, self.__cache_ttl)
iterator = Iterator(fetchers=[Fetcher([self.__cache])])
packages = self.filter_packages_by_interpreter(
Copy link
Contributor

Choose a reason for hiding this comment

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

should probably kill the packages = [] above btw.

@kwlzn kwlzn mentioned this pull request Mar 6, 2017
@butlern
Copy link
Contributor Author

butlern commented Mar 7, 2017

Sounds good, removed packages=[] and set default ttl to 3600.

@kwlzn kwlzn merged commit 31d624b into pex-tool:master Mar 7, 2017
@kwlzn
Copy link
Contributor

kwlzn commented Mar 7, 2017

@butlern merged. thanks for the PR!

butlern added a commit to butlern/pex that referenced this pull request Jun 30, 2017
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pex throws a resolution error when using cache, succeeds otherwise
2 participants