Repository navigation
Closed
Description
On current master distributed-2.9.1+13.g7d2ed43c (and tornado==6.0.3), I get the following error on MacOS but not in Docker:
# already running dask scheduler
(.venv) ➜ model git:(nyc) ✗ PYTHONPATH=. dask-worker 'localhost:8786' --nthreads 1 --memory-limit 6GB --local-directory /tmp/ --nprocs 1
distributed.nanny - INFO - Start Nanny at: 'tcp://127.0.0.1:55985'
objc[39479]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[39479]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
distributed.nanny - INFO - Worker process 39479 was killed by signal 6
tornado.application - ERROR - Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x118220490>>, <Task finished coro=<Nanny._on_exit() done, defined at /Users/brett/model/.venv/lib/python3.7/site-packages/distributed/nanny.py:396> exception=TypeError('addresses should be strings or tuples, got None')>)
Traceback (most recent call last):
File "/Users/brett/model/.venv/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
ret = callback()
File "/Users/brett/model/.venv/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
future.result()
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/nanny.py", line 399, in _on_exit
await self.scheduler.unregister(address=self.worker_address)
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/core.py", line 757, in send_recv_from_rpc
result = await send_recv(comm=comm, op=key, **kwargs)
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/core.py", line 556, in send_recv
raise exc.with_traceback(tb)
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/core.py", line 408, in handle_comm
result = handler(comm, **msg)
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/scheduler.py", line 2122, in remove_worker
address = self.coerce_address(address)
File "/Users/brett/model/.venv/lib/python3.7/site-packages/distributed/scheduler.py", line 4831, in coerce_address
raise TypeError("addresses should be strings or tuples, got %r" % (addr,))
TypeError: addresses should be strings or tuples, got None
distributed.nanny - INFO - Closing Nanny at 'tcp://127.0.0.1:55985'
distributed.dask_worker - INFO - End worker
No issues in the latest release (2.9.1). Possibly related to #3356 but I didn't see any similar error messages so I figured I'd keep it separate for now.
Reacted by Isaac Virshup
Metadata
Metadata
Assignees
Labels
No labels
Activity
quasiben commentedon Jan 15, 2020
I have a similar setup on MacOS but I can't reproduce. Can you also post your dask version ?
mrocklin commentedon Jan 15, 2020
bnaul commentedon Jan 15, 2020
Hmm, I'm also not able to reproduce on a fresh virtualenv so perhaps it's related to some other installed packages. I'll try something like a
bisecton mypip freezeand see what I find :)bnaul commentedon Jan 20, 2020
@mrocklin I did a bisect and found the offending commit:
32cb96effe9287fdc42dd73be36989be13abe99d is the first bad commit.Still having trouble nailing down exactly which other packages are causing a conflict (sort of hard to really "bisect" when there's so many interdependencies between things) but maybe something about that commit rings a bell to someone..?
bnaul commentedon Jan 20, 2020
Update: there seems to be a bad interaction w/ bokeh..? But I still can't recreate on a fresh environment + distributed + bokeh so there's more to it than that 🤔
mrocklin commentedon Jan 20, 2020
Interesting. @bnaul can I ask you to try out #3394 ?
mrocklin commentedon Jan 20, 2020
Wait, nm, scratch that. I got my comments crossed.
bnaul commentedon Jan 20, 2020
Found the offending line: 32cb96e#diff-14c5e43ed851ac4e461cda22da5340a8L24. Adding
pandasback to this list fixes the issue for me on master.Maybe something to do with the order of imports? I couldn't reproduce by stepping through in a debugger so it could also just be a very sensitive race condition...?
Also forgot to mention above but
--no-nannyalso avoids the issuemrocklin commentedon Jan 20, 2020
Wow, that's a weird thing to hang on.
Can I ask you to add a
time.sleep(0.5)in theget_versionfunction and see if that would also make the problem go away? Pandas is notable in that it takes a little bit of time to import.mrocklin commentedon Jan 20, 2020
(also, thanks for searching and finding that there)
bnaul commentedon Jan 20, 2020
I've been sprinkling some sleeps and can't seem to fix it but given the error message I assume it has to do with
set_forkserver_preload(preload)wherepreloadcomes from{required,optional}_packagesbnaul commentedon Jan 27, 2020
@mrocklin any suggestions for a possible workaround for this? @quasiben if you'd like to try to reproduce, the following steps work for me on 3.7.6:
Full resulting package list:
jrbourbeau commentedon Jan 27, 2020
Thanks for the continuing to investigate on this @bnaul! I installed the set of packages listed (copied the full list into a
requirements.txtfile andpip installed them) in a fresh conda environment with Python 3.7.6, but wasn't able to reproduce the error. Here's the output I get after runningdask-worker localhost:8786 --nanny:dask worker output:
We had a report about test failures on MacOS over in #3356. Just a shot in the dark, but does @quasiben's comment over there (#3356 (comment) and the following comment) apply to your system?
bnaul commentedon Jan 27, 2020
I don't believe that's related based on the errors. @jrbourbeau any chance you're able to try w/ a
homebrewPython install instead ofconda? That seems like a pretty big difference and likely to explain the discrepancy.jrbourbeau commentedon Jan 27, 2020
Still getting a similar output when using Python 3.7.6 from homebrew:
1 remaining item
jrbourbeau commentedon Jan 28, 2020
Ah, I see! Yes, I am on Catalina
quasiben commentedon Jan 28, 2020
I am now able to reproduce. I am on Mojave, I used brew to build a venv and pip installed same as @jrbourbeau . I am also getting a lovely pop up with the following details:
Details
Termination Reason: Namespace OBJC, Code 0x1Application Specific Information:
objc[74025]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
crashed on child side of fork pre-exec
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00007fff77fee016 __abort_with_payload + 10
1 libsystem_kernel.dylib 0x00007fff77fe95db abort_with_payload_wrapper_internal + 82
2 libsystem_kernel.dylib 0x00007fff77fe9589 abort_with_reason + 22
3 libobjc.A.dylib 0x00007fff766cf8dd _objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 108
4 libobjc.A.dylib 0x00007fff766cf78f _objc_fatal(char const*, ...) + 135
5 libobjc.A.dylib 0x00007fff766d060f performForkChildInitialize(objc_class*, objc_class*) + 341
6 libobjc.A.dylib 0x00007fff766d162f initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt&, bool) + 187
7 libobjc.A.dylib 0x00007fff766c0690 lookUpImpOrForward + 228
8 libobjc.A.dylib 0x00007fff766c0114 _objc_msgSend_uncached + 68
9 libobjc.A.dylib 0x00007fff766c369b +[NSObject new] + 86
10 com.apple.Foundation 0x00007fff4e18f478 -[NSThread init] + 61
11 com.apple.Foundation 0x00007fff4e18f3e2 ____NSThreads_block_invoke + 64
12 libdispatch.dylib 0x00007fff77e4e63d _dispatch_client_callout + 8
13 libdispatch.dylib 0x00007fff77e4fd4b _dispatch_once_callout + 20
14 com.apple.Foundation 0x00007fff4e18f39d _NSThreadGet0 + 325
15 com.apple.Foundation 0x00007fff4e18ec31 _NSInitializePlatform + 407
16 libobjc.A.dylib 0x00007fff766c1d51 call_load_methods + 233
17 libobjc.A.dylib 0x00007fff766bf405 load_images + 117
18 dyld 0x000000011bdcb46a dyld::notifySingle(dyld_image_states, ImageLoader const*,
--no-nannyalso resolves the issue. Additionally, usingspawnfor themultiprocessing-methodin~/.config/dask/distributed.yamlalso resolves the problemDigging a little more into brew and multiprocessing, it appears that this has been an issue in the past:
https://bugs.python.org/issue33725
jakirkham commentedon Jan 28, 2020
@quasiben, I think that is because Apple made it so that Grand Central Dispatch will error when forking (as it is not fork safe). This comes up commonly in the PyData ecosystem when libraries (like NumPy and SciPy) link against macOS's native BLAS library, Accelerate, which uses Grand Central Dispatch for threading. Spawning instead of forking fixes this issue. Alternatively using a different BLAS implementation (like OpenBLAS) avoids linking to Grand Central Dispatch thus also fixing this issue.
jakirkham commentedon Jan 28, 2020
So @bnaul have you tried using spawn?
bnaul commentedon Jan 30, 2020
Yep,
spawnworks for me; if this is a MacOS problem then I guess it makes sense to close? Or maybe at least document somehow...? Will leave it up to youjakirkham commentedon Jan 30, 2020
Agree documentation is probably valuable. I wouldn't assume most users would know about this problem. Is this something you would be interested in writing up? 😉
medley56 commentedon Feb 7, 2020
We're seeing this forking issue when using
distributed.utils_test.clientin our unit tests. Any ideas for a fix?quasiben commentedon Feb 7, 2020
@medley56 have you tried the workout outlined in #3374 (comment)
medley56 commentedon Feb 7, 2020
@quasiben Sorry, I meant is there any chance of a fix in distributed? After doing a bit more research though, it seems like the problem is deeper in MacOS and something to do with objective C's process forking being unsafe.
The workaround in #3374 seems to work.
jakirkham commentedon Feb 9, 2020
Not sure what you mean by a fix in Distributed. As you noted, the OS is making this choice. More details in this comment. So there’s not too much Distributed can really do unfortunately.
bnaul commentedon Feb 9, 2020
I basically agree with this, but I would also point out that before this change this issue didn't occur for whatever mysterious reason. spawn is working for me but since forkserver is still the default, maybe it's worth thinking about whether there's a workaround? Documentation isn't really sufficient IMO if
distributed.Client()just crashes right out of the gate for most Mac users...mrocklin commentedon Feb 9, 2020
So one solution would be to route forkserver -> spawn on OSX. That is here: #3460
Another solution would be to use spawn everywhere. I'm toying around with this now.
mrocklin commentedon Feb 9, 2020
Setting things to spawn actually makes the
client = Client()experience a bit faster, down from 2s to 1.2s on my machine. However it seems to make themultiprocessing.Pipes that we use to detect broken connections somewhat noisy.mrocklin commentedon Feb 9, 2020
Here is an alternative: #3461