Print a message for cycles in the graph when computing the target fingerprint

Review Request #4087 - Created July 18, 2016 and submitted

Information
Eric Ayers
pants
zundel/remove-more-build-aux
3681
e63cf7c...
Reviewers
pants-reviews
benjyw, patricklaw, stuhood

While hand editing a BUILD file I introduced a cycle in the graph. The error was:

21:35:47 00:03   [complete]
               FAILURE
Exception caught: (<class 'pants.invalidation.cache_manager.CacheValidationError'>)

Exception message: Problem validating target project.tests.src.test.proto.proto in project/tests/src/test/proto: maximum recursion depth exceeded

The stack trace showed:

  ...
  File "pantsbuild.pants-1.1.0_pre6_square_20160707_01-py2-none-any.whl/pan
ts/build_graph/target.py", line 464, in dep_hash_iter
    dep_hash = dep.transitive_invalidation_hash(fingerprint_strategy)
  File "pantsbuild.pants-1.1.0_pre6_square_20160707_01-py2-none-any.whl/pan
ts/build_graph/target.py", line 467, in transitive_invalidation_hash
    dep_hashes = sorted(list(dep_hash_iter()))
  ...

This patch fixes it by trakcing the depth of these recursive calls and abort with an AddressLookupError so that we can see a trace. Now the error looks like:

Exception caught: (<class 'pants.invalidation.cache_manager.CacheValidationError'>)

Exception message: Problem validating target service.container.tests.src.test.proto.proto in service/container/tests/src/test/proto: Max depth of 300 exceeded.
  referenced from 3rdparty:com.google.inject.guice
  referenced from otherproject/components/cronjobs/annotations/src/main/java:lib
  referenced from otherproject/components/cronjobs/annotations/src/main/java:cron-jobs-processor
  referenced from otherproject/components/cronjobs/annotations/src/main/java:lib
  referenced from otherproject/components/cronjobs/annotations/src/main/java:cron-jobs-processor
  referenced from otherproject/components/cronjobs/annotations/src/main/java:lib
  ...

Added unit test.

CI running at https://travis-ci.org/pantsbuild/pants/builds/145436454

Benjy Weinberger
Stu Hood
Benjy Weinberger
Eric Ayers
Eric Ayers
Review request changed

Status: Closed (submitted)

Change Summary:

Commit a2fe1dc

Loading...