Skip to content

KeyError during replication #3990

Closed
Closed

Description

@mdering

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?

Activity

  1. quasiben commented on Jul 28, 2020

    @quasiben
    Member

    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 ?

  2. jakirkham commented on Jul 31, 2020

    @jakirkham
    Member

    Any updates here, @mdering? We probably need some more info here to be helpful 🙂

  3. mdering commented on Jul 31, 2020

    @mdering
    Author

    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

  4. jakirkham commented on Jul 31, 2020

    @jakirkham
    Member

    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.

  5. mdering commented on Jul 31, 2020

    @mdering
    Author

    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.

  6. jakirkham commented on Jul 31, 2020

    @jakirkham
    Member

    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.

  7. mdering commented on Jul 31, 2020

    @mdering
    Author

    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.

  8. jakirkham commented on Jul 31, 2020

    @jakirkham
    Member

    Always a possibility.

    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.

  9. mrocklin commented on Jul 31, 2020

    @mrocklin
    Member
  10. added
    stability
    on Jun 15, 2022
  11. crusaderky commented on Jun 15, 2022

    @crusaderky
    Collaborator

    Closing as a duplicate of #6578

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

    memorystability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions