Skip to content

Fix bug in cached dependency resolution with exact resolvable#365

Merged
kwlzn merged 3 commits into
pex-tool:masterfrom
butlern:fix_pinned_resolvable_bug
Mar 7, 2017
Merged

Fix bug in cached dependency resolution with exact resolvable#365
kwlzn merged 3 commits into
pex-tool:masterfrom
butlern:fix_pinned_resolvable_bug

Conversation

@butlern
Copy link
Copy Markdown
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
Copy Markdown
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?

Comment thread pex/resolver.py
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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