-
-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduler TaskState
objects should be unique, not hashed by key
#7510
Comments
I would strongly advise against using I generally second having unique logical tasks, but I am not certain if simply removing |
Ah, thanks for clarifying. Makes sense, I hadn't looked that carefully at what
No, because in the subsequent distributed/distributed/scheduler.py Lines 4408 to 4410 in d74f500
|
I'm not entirely convinced that simply swapping out the hash function is sufficient. Most mappings that include TaskState objects still use the |
What mappings hold
I don't claim that just swapping the hash function is sufficient to resolve all problems with re-submitted tasks and stale TaskState objects with the same key. I'm just saying it's more correct, and it would resolve problems that can occur when storing It would fix #7504, and seems like the correct behavior—is there a reason not to do it? |
My argument is more general. I don't think distributed should use keys internally for most of what it is using them for right now. That's a bigger topic, of course.
Not pushing back on this. If you can produce a test for it, I'm happy |
Currently, two
TaskState
objects with the same key will hash and compare as equal. However, there should only ever be oneTaskState
object per logical task. Therefore, if there are twoTaskState
objects with the same key, they must refer to logically different tasks—such as the same key being re-submitted—and should not be equal, nor hash the same. They refer to different things.Using the key as the hash causes errors like #7504.
This is a similar theme to:
@crusaderky already fixed the equivalent problem on the worker side in #6593.
Like there, I think we should simply remove
__hash__
and__eq__
fromTaskState
on the scheduler. Then we'll automatically get what we want, where onlyTaskState
s with the sameid
are equal:See prior discussion in #6593 (comment), #6585 (comment).
Note that I could see an argument for instead including the recently-added
run_id
#7463 in the hash, in order to disambiguate between reruns of the same key. That would probably also fix things, for now, but I don't see the advantage of it. Since there should never be multipleTaskState
s per task in the first place, what's the need for a custom__hash__
or__eq__
method? The default identity-based method is the simplest and most correct.The text was updated successfully, but these errors were encountered: