Skip to content

2021.7.1 hangs when executing a from_pandas task with distributed.worker - ERROR - ('memory', 'executing') #5119

Closed

Description

@bsesar

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

Activity

  1. changed the title [-]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')[/+] on Jul 26, 2021
  2. fjetter commented on Jul 28, 2021

    @fjetter
    Member

    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.

  3. bsesar commented on Jul 29, 2021

    @bsesar
    Author

    @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.

  4. bsesar commented on Jul 29, 2021

    @bsesar
    Author

    To add another data point, the above code finishes if instead of the distributed scheduler I use the default "processes" or "threads" scheduler (i.e., dask.config.set(scheduler='processes') or dask.config.set(scheduler='threads')). @fjetter, you may be on to something with your fix :-)

  5. fjetter commented on Jul 29, 2021

    @fjetter
    Member

    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.

    I use the default "processes" or "threads" scheduler

    If you are using these schedulers, dask is using a very simple ThreadPool or ProcessPool executor of the concurrent.futures library. 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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions