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

[pantsd] Multiple pantsd runs piped by xargs cause a spurious exception. #7815

Closed
blorente opened this issue May 29, 2019 · 3 comments
Closed
Labels

Comments

@blorente
Copy link
Contributor

blorente commented May 29, 2019

When I pipe two pants runs together with an xargs in between them, I get an exception when the NailgunStreamWriter of the first run tries to remove a file descriptor twice (because it errored):

$ ./pants --pantsd list src/scala:: | xargs ./pants --pantsd filedeps
Exception in thread NailgunStreamWriter:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/Users/bescobar/workspace/otherpants/src/python/pants/java/nailgun_io.py", line 229, in run
    self.do_run(readable_fds, errored_fds)
  File "/Users/bescobar/workspace/otherpants/src/python/pants/java/nailgun_io.py", line 247, in do_run
    self.stop_reading_from_fd(fileno)
  File "/Users/bescobar/workspace/otherpants/src/python/pants/java/nailgun_io.py", line 224, in stop_reading_from_fd
    self._in_fds.remove(fileno)
ValueError: list.remove(x): x not in list

/Users/bescobar/workspace/otherpants/3rdparty/jvm/org/pantsbuild/buck/util/zip/BUILD
... (correct output)

This doesn't happen if we pipe to xargs but not another pants run:

$ ./pants --pantsd filedeps src/scala:: | parallel grep "BUILD" {} \;

# This BUILD file defines common external library dependencies used across many modules.  Modules
# If you're looking at this BUILD file for inspiration organizing your own project's 3rdparty

The overall exit code is 0 in both cases.

My current hypothesis is that the second pants run closes the socket ahead of time, but I don't really know.

@stuhood
Copy link
Member

stuhood commented May 29, 2019

This will deadlock in many cases, unfortunately (although with a nice error message now!). So while cleaning up the exception would be good, we need to be discouraging this pattern.

@blorente
Copy link
Contributor Author

Thanks!

@stuhood
Copy link
Member

stuhood commented Mar 4, 2021

This was fixed by #11147. Hooray!

Avoiding the (potential) deadlock of the first case on large runs will be resolved by #7654.

@stuhood stuhood closed this as completed Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants