I'm encountering a persistent issue with Dask serialization when updating my flows from Prefect `2.1...
r

Robert Banick

over 1 year ago
I'm encountering a persistent issue with Dask serialization when updating my flows from Prefect
2.19.1
to Prefect
3.1.2
. Every run incurs the following error, which I've never seen before in 18 months of using Prefect 2:
Task run failed with exception: TypeError('Could not serialize object of type HighLevelGraph', '<ToPickle: HighLevelGraph with 1 layers.\n<dask.highlevelgraph.HighLevelGraph object at 0x7f4e3b547400>\n 0. 139974151916736\n>') - Retries are exhausted
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/distributed/protocol/pickle.py", line 63, in dumps
    result = pickle.dumps(x, **dump_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/prefect/docker/__init__.py", line 20, in __getattr__
    raise ImportError(f"module {__name__!r} has no attribute {name!r}")
ImportError: module 'prefect.docker' has no attribute 'isnan'

<---Long series of stack traces--->

The above exception was the direct cause of the following exception:

<<---Long stack trace--->>

  File "/usr/local/lib/python3.10/dist-packages/distributed/protocol/serialize.py", line 392, in serialize
    raise TypeError(msg, str_x) from exc
TypeError: ('Could not serialize object of type HighLevelGraph', '<ToPickle: HighLevelGraph with 1 layers.\n<dask.highlevelgraph.HighLevelGraph object at 0x7f4e3b547400>\n 0. 139974151916736\n>')
All of my flows write to Zarr N-Dimensional data stores using Xarray's
to_zarr
method,.
to_zarr
leverages Dask under the hood to vastly speed up this operation. I don't use Dask Task Runners or any specialized Prefect Dask objects. Digging around I've found this conversation, which doesn't seem directly related https://linen.prefect.io/t/23198687/hello-everyone-i-m-facing-an-issue-using-prefect-with-a-dask. Any ideas Prefect team? I'll post a full stack trace in follow up
I'm having trouble with crashing async tasks and I'm not sure how to troubleshoot it. I'm using thi...
r

Richard Alexander

over 2 years ago
I'm having trouble with crashing async tasks and I'm not sure how to troubleshoot it. I'm using this pattern within a flow to start the tasks concurrently:
coros = []
for item in item_list:
    coros.append(task1(item , return_state=True))
    coros.append(task2(item , return_state=True))
    coros.append(task3(item , return_state=True))
    coros.append(task4(item , return_state=True))

    states = await asyncio.gather(*coros)
For a small
item_list
, everything works fine. But if
item_list
approaches 100 items, almost all of the async tasks crash. I'm not seeing anything helpful in the logs to indicate why the tasks crash, so I'm wondering how to go about troubleshooting/fixing this async flow for large lists. Each crashed task shows this error message:
Crash detected! Execution was cancelled by the runtime environment.
How can I figure out why execution was canceled? Is there any other logging source that I should be looking at outside of the Prefect logs? Or do I need to increase my log level for this type of issue? Or do I need to calculate how many workers are needed in the work pool to handle large lists? Background info (in case it's useful): • Prefect version 2.16.2 • The compute instance is very large. It has 12 cores and 62G memory. • The compute and memory footprint of each task is small (each is calling an API and waiting for a response) • I'm using work pools and all tasks are being sent to the same work pool.