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] Pantsd tries to write to a closed file when dying. #7613

Closed
blorente opened this issue Apr 23, 2019 · 1 comment · Fixed by #9722
Closed

[pantsd] Pantsd tries to write to a closed file when dying. #7613

blorente opened this issue Apr 23, 2019 · 1 comment · Fixed by #9722

Comments

@blorente
Copy link
Contributor

When running ./pants --enable-pantsd filter testprojects:: && ./pants kill-pantsd, the log doesn't render the exception properly, because out (possibly sys.stderr is closed when trying to write to it in exiter.py:

...
19:08:54 [INFO] pailgun request completed: `./pants --enable-pantsd filter testprojects::`
19:08:54 [INFO] enqueuing 24638 changes for subscription all_files
19:08:54 [INFO] confirmed watchman subscription: {'clock': 'c:1556046529:86379:1:3', 'subscribe': 'pantsd_pid', 'version': '4.9.1'}
19:08:54 [INFO] enqueuing 1 changes for subscription pantsd_pid
19:08:57 [WARN] Encountered error when trying to log this message: b'timestamp: 2019-04-23T20:08:57.454457\nSignal 15 (SIGTERM) was raised. Exiting with failure.\n  File "/Users/bescobar/workspace/pants/src/python/pants/bin/pants_loader.py", line 89, in <module>\n    main()\n  File "/Users/bescobar/workspace/pants/src/python/pants/bin/pants_loader.py", line 85, in main\n    PantsLoader.run()\n  File "/Users/bescobar/workspace/pants/src/python/pants/bin/pants_loader.py", line 81, in run\n    cls.load_and_execute(entrypoint)\n  File "/Users/bescobar/workspace/pants/src/python/pants/bin/pants_loader.py", line 74, in load_and_execute\n    entrypoint_main()\n  File "/Users/bescobar/workspace/pants/src/python/pants/pantsd/pants_daemon.py", line 475, in launch\n    PantsDaemon.Factory.create(OptionsBootstrapper.create()).run_sync()\n  File "/Users/bescobar/workspace/pants/src/python/pants/pantsd/pants_daemon.py", line 408, in run_sync\n    self._run_services(self._services)\n  File "/Users/bescobar/workspace/pants/src/python/pants/pantsd/pants_daemon.py", line 363, in _run_services\n    service_thread.join(self.JOIN_TIMEOUT_SECONDS)\n  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 1036, in join\n    self._wait_for_tstate_lock(timeout=max(timeout, 0))\n  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock\n    elif lock.acquire(block, timeout):\n  File "/Users/bescobar/workspace/pants/src/python/pants/base/exception_sink.py", line 74, in handle_sigterm\n    raise self.SignalHandledNonLocalExit(signum, \'SIGTERM\')\n  File "/Users/bescobar/workspace/pants/src/python/pants/base/exception_sink.py", line 67, in __init__\n    self.traceback_lines = traceback.format_stack()\n\n\n'
@blorente blorente changed the title Pantsd tries to write to a closed file when dying. [pantsd] Pantsd tries to write to a closed file when dying. Apr 23, 2019
@stuhood
Copy link
Member

stuhood commented Apr 23, 2019

And the theory is that this is not related to the implementation of kill-pantsd: only to receiving a signal.

stuhood pushed a commit that referenced this issue May 13, 2020
### Problem

The setup and teardown of each request made to the nailgun server in `pantsd` had become quite complicated over time... and consequently, slower than it needed to be.

### Solution

Port `pantsd`'s nailgun server to rust using the `nails` crate. Additionally, remove the `Exiter` class, which had accumulated excess responsibilities that can instead be handled by returning `ExitCode` values. Finally, fix a few broken windows including: double logging to pantsd, double help output, closed file errors on pantsd shutdown, and redundant setup codepaths.

### Result

There is less code to maintain, and runs of `./pants --enable-pantsd help` take `~1.7s`, of which `~400ms` are spent in the server. Fixes #9448, fixes #8243, fixes #8206, fixes #8127, fixes #7653, fixes #7613, fixes #7597.
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 a pull request may close this issue.

2 participants