You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What happened:
I'm implementing a distributed system that has pretty active replication logic, as well as a good amount of workers starting and stopping. Currently I have a method that replicates specific futures that hold valuable intermediate results. However, during this, it seems like a keyerror can occur when a worker goes down during the replication process. I think this is because a worker is retired in the middle of this process (probably due to high memory usage).
Traceback (most recent call last):
File "/opt/conda/envs/env/lib/python3.7/site-packages/distributed/core.py", line 513, in handle_comm
result = await result
File "/opt/conda/envs/env/lib/python3.7/site-packages/distributed/scheduler.py", line 3255, in replicate
for ws, tasks in del_worker_tasks.items()
File "/opt/conda/envs/env/lib/python3.7/site-packages/distributed/scheduler.py", line 3064, in _delete_worker_data
ts.who_has.remove(ws)
is there any reason why this error can't be caught and ignored?
What you expected to happen:
I would expect this not to happen. Minimal Complete Verifiable Example:
Sorry, I don't really have this, but maybe we could force it by allocating a lot of memory on workers and calling replicate on them?
I don't see what the error is in the post above. I only see a few lines of the traceback of where the error occurred. How are you replicating futures ?
I think this has to do with the replication during a worker shutdown. We're currently using workers who cycle in and out pretty regularly due to high memory use, specifically i think this surfaced during a replication-stimulated delete of a future off of a worker that was shutting down. Once I altered the code to only replicate the futures that were only on < n workers, this issue went away. I thought a stack trace would be helpful here. I'm sorry I can't provide more info but this feels like something the library should be able to handle
My only suggestion at this point would be to cutdown on the amount of memory in each task (if possible). Like working with a smaller amount of data and possibly optimizing functions within tasks to have a lower memory footprint (working in-place is often useful). We do try to spill memory (we know about) to disk based on periodic polling of system memory. The OS can also do this itself. That said, there are practical limits on these. So being mindful of memory usage in tasks remains important.
sure, I get that but we have some memory spikes in our code, and for testing are keeping memory limits low. We had been doing periodic restarts as well and may return to this. I know that having workers enter and exit should be pretty graceful, but this might be liable to happen in adaptive cluster settings as well.
Are there particular kinds of functions that seem to get high memory usage?
That's a fair point and sounds like something worth focusing on. I wonder if we might be able to come up with some cases where the adaptive cluster doesn't communicate data well before closing workers down.
I'm not sure. It wouldn't surprise me if we have a little memory leak too. Either way its not memory thats managed by dask and were happy enough to let workers enter and exit whenever, but it does seem to cause strange issues in strange places. Replicate through a comms error because it was trying to replicate to a worker that went down. We're also seeing issues like #4001 as well.
Running through the code with tracemalloc can be a useful exercise. If NumPy is involved, it uses its own domain, which can be useful to filter out unrelated allocations. Another useful tool is memprof, which is like line_profiler with memory.
Is it possible some of this memory that is unknown to Dask doesn't serialize between workers? If so, it might be worth figuring out a way to graduate this into Python somehow so that Dask can get a handle on it. Just another thought 🙂
Should add it's still possible there is a bug in adaptive as well. Just trying to give some ideas as to where one might look further.
Replicate isn't super robust. That and rebalance both have consistency
issues and should only be fully trusted when the cluster is in a quiet
state. They *may *still work in an active state, but the code there isn't
bullet proof. Long-term I think that the solution to this is to rework
active memory management. In the meantime if people want to jump into the
replicate code with patches that would be welcome, but it may be a
moderately large effort.
Activity
quasiben commentedon Jul 28, 2020
I don't see what the error is in the post above. I only see a few lines of the traceback of where the error occurred. How are you replicating futures ?
jakirkham commentedon Jul 31, 2020
Any updates here, @mdering? We probably need some more info here to be helpful 🙂
mdering commentedon Jul 31, 2020
I think this has to do with the replication during a worker shutdown. We're currently using workers who cycle in and out pretty regularly due to high memory use, specifically i think this surfaced during a replication-stimulated delete of a future off of a worker that was shutting down. Once I altered the code to only replicate the futures that were only on < n workers, this issue went away. I thought a stack trace would be helpful here. I'm sorry I can't provide more info but this feels like something the library should be able to handle
jakirkham commentedon Jul 31, 2020
My only suggestion at this point would be to cutdown on the amount of memory in each task (if possible). Like working with a smaller amount of data and possibly optimizing functions within tasks to have a lower memory footprint (working in-place is often useful). We do try to spill memory (we know about) to disk based on periodic polling of system memory. The OS can also do this itself. That said, there are practical limits on these. So being mindful of memory usage in tasks remains important.
mdering commentedon Jul 31, 2020
sure, I get that but we have some memory spikes in our code, and for testing are keeping memory limits low. We had been doing periodic restarts as well and may return to this. I know that having workers enter and exit should be pretty graceful, but this might be liable to happen in adaptive cluster settings as well.
jakirkham commentedon Jul 31, 2020
Are there particular kinds of functions that seem to get high memory usage?
That's a fair point and sounds like something worth focusing on. I wonder if we might be able to come up with some cases where the adaptive cluster doesn't communicate data well before closing workers down.
mdering commentedon Jul 31, 2020
I'm not sure. It wouldn't surprise me if we have a little memory leak too. Either way its not memory thats managed by dask and were happy enough to let workers enter and exit whenever, but it does seem to cause strange issues in strange places. Replicate through a comms error because it was trying to replicate to a worker that went down. We're also seeing issues like #4001 as well.
jakirkham commentedon Jul 31, 2020
Always a possibility.
Running through the code with
tracemalloccan be a useful exercise. If NumPy is involved, it uses its own domain, which can be useful to filter out unrelated allocations. Another useful tool is memprof, which is likeline_profilerwith memory.Is it possible some of this memory that is unknown to Dask doesn't serialize between workers? If so, it might be worth figuring out a way to graduate this into Python somehow so that Dask can get a handle on it. Just another thought 🙂
Should add it's still possible there is a bug in adaptive as well. Just trying to give some ideas as to where one might look further.
mrocklin commentedon Jul 31, 2020
crusaderky commentedon Jun 15, 2022
Closing as a duplicate of #6578