Repository navigation
Closed
Description
What happened: The MCV example below works if Pandas DataFrame has 28 million rows, but it does not work for 29 million rows.
What you expected to happen: The code should print out Success writing 29000000 rows, indicating that it successfully went through the loop.
Minimal Complete Verifiable Example:
import multiprocessing.popen_spawn_win32
from dask.distributed import Client
import dask.dataframe as dd
import pandas as pd
from shutil import rmtree
import numpy as np
client = Client()
for Nrows in [28e6, 29e6]:
# create a Pandas DataFrame
df = pd.DataFrame(np.random.randn(int(Nrows), 2), columns=list('AB'), index=pd.util.testing.rands_array(16, int(Nrows), dtype='O'))
# create a Dask DataFrame
ddf = dd.from_pandas(df, npartitions=240)
# dump the DataFrame to CSV
ddf.to_csv('output_%d' % int(Nrows))
print('Success writing %d rows.' % int(Nrows))
rmtree('output_%d' % int(Nrows)) And here is the output
Success writing 28000000 rows.
distributed.worker - ERROR - ('memory', 'executing')
Traceback (most recent call last):
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\distributed\worker.py", line 2841, in ensure_computing
self.transition(ts, "executing")
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\distributed\worker.py", line 1692, in transition
func = self._transitions[start, finish]
KeyError: ('memory', 'executing')
tornado.application - ERROR - Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOLoop object at 0x00000224D5339550>>, <Task finished name='Task-5138' coro=<Worker.ensure_computing() done, defined at C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\distributed\worker.py:2805> exception=KeyError(('memory', 'executing'))>)
Traceback (most recent call last):
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
ret = callback()
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\tornado\ioloop.py", line 765, in _discard_future_result
future.result()
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\distributed\worker.py", line 2841, in ensure_computing
self.transition(ts, "executing")
File "C:\Users\--\AppData\Local\Continuum\anaconda3\envs\work2\lib\site-packages\distributed\worker.py", line 1692, in transition
func = self._transitions[start, finish]
KeyError: ('memory', 'executing')
Anything else we need to know?: I've reported this issue previously as #5047 and dask/dask#7848. On a different machine with Windows Server 2016 64 bits and Python 3.9.6, the code hangs without any error reported.
Environment:
- Dask version: 2021.7.1
- Python version: 3.8.10
- Operating System: Windows 10 Enterprise 1909
- Install method (conda, pip, source): conda
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]2021.7.1 hangs when executing a from_pandas task with no error reported[/-][+]2021.7.1 hangs when executing a from_pandas task with distributed.worker - ERROR - ('memory', 'executing')[/+]fjetter commentedon Jul 28, 2021
Hi @bsesar ! Thanks for the report. I couldn't reproduce your issue on my machine but with #5128 I am resolving a deadlock and am removing the only code path which can trigger the above mentioned keyerror.
bsesar commentedon Jul 29, 2021
@fjetter, just to make it clear, you could not reproduce my issue with 2021.7.1 or with #5128 fix in place? If the former, I would be interested in seeing your requirements.txt.
bsesar commentedon Jul 29, 2021
To add another data point, the above code finishes if instead of the
distributedscheduler I use the default "processes" or "threads" scheduler (i.e.,dask.config.set(scheduler='processes')ordask.config.set(scheduler='threads')). @fjetter, you may be on to something with your fix :-)fjetter commentedon Jul 29, 2021
I couldn't reproduce it on main, nor on 2021.7.1. My requirements.txt doesn't really factor into this as much that it is a different system I'm running on. Different CPU, different OS, different timings. It may be the case that it is a good reproducer on your machine but these things are heavily timing sensitive and your producer still relies on chance. FWIW I could reproduce a different issue with your code but not the one you are reporting.
If you are using these schedulers, dask is using a very simple ThreadPool or ProcessPool executor of the
concurrent.futureslibrary. It will "stupidly" execute the tasks based on a topological ordering. There is no way anything can deadlock unless the executors themselves break down.If you are using a client/cluster you're using dask.distributed as the "executor" which is quite a different beast. It should perform much better though; assuming it doesn't deadlock ;)