Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17759] [CORE] Avoid adding duplicate schedulables - #15326
[SPARK-17759] [CORE] Avoid adding duplicate schedulables#15326erenavsarogullari wants to merge 5 commits into
Conversation
markhamstra
commented
Oct 3, 2016
I've got some issues with this PR.
overridedefaddSchedulable(schedulable: Schedulable) {
require(schedulable !=null)
valname= schedulable.name
if (null== schedulableNameToSchedulable.put(name, schedulable)) {
schedulableQueue.add(schedulable)
} else {
logWarning(s"Duplicate Schedulable added: $name")
// remove previously enqueued schedulable with same name
schedulableQueue.remove(getSchedulableByName(name))
if (!schedulableQueue.contains(schedulable)) {
schedulableQueue.add(schedulable)
}
}
schedulable.parent =this
}The only routes to this code are from the one-time initialization of the backend on the creation of a SparkContext and from This is also the only route by which a This should pass all the existing tests; but if you do something more severe than just logging the warning (such as adding a |
kayousterhout
commented
Oct 3, 2016
+1 to Mark's suggestion about putting the behavior in Pool::addSchedulable, so that it works across all Schedulables. I'm less convinced about maintaining the existing behavior where the last added pool wins. I think people usually expect first-wins behavior for these things (e.g., that's the case for Java classpath issues), and the code is also simpler for that approach. Given that this should be affecting pretty few people (and there's now a warning logged), I think this would be fine to change. |
markhamstra
commented
Oct 3, 2016
@kayousterhout@rxin Ok, but if we're going to change the behavior, then we need to be sure that change at least makes it into the release notes. |
kayousterhout
commented
Oct 3, 2016
@markhamstra if we do change it, we should prob merge only into master and not 2.0.1. |
markhamstra
commented
Oct 3, 2016
Yes, that is what I was thinking regardless. |
markhamstra
commented
Oct 3, 2016
...and it would be 2.0.2 at this point. :) |
Firstly, thanks @markhamstra and @kayousterhout for quick feedbacks. I was aware of putting the check in
and if there is a case that a |
markhamstra
commented
Oct 3, 2016
@erenavsarogullari Your concern was entirely legitimate, and is also why I called in @kayousterhout to double-check my claim that other duplicate Schedulables would also be a problem. |
@erenavsarogullari@markhamstra I just looked at this further and I actually think this could be an issue: (1) The first attempt for a stage fails with a fetch failure. The associated TaskSetManager is marked as a zombie but some tasks are still running, so removeSchedulable isn't called yet (it gets called in TaskSchedulerImpl only after all running tasks in the stage have finished). (2) The map stage re-runs and a new attempt for the stage begins. This attempt has the same stage ID, so will have the same schedulable name. I remember having a long discussion about (1) a while ago (and when we should call removeSchedulable) and decided it was most "fair" to call it only after all running tasks complete, because running tasks should be counted towards the pools share even when they're for zombie task sets. I think in this case, the last-schedulable-wins policy that currently exists seems better, although still wrong. I'd argue we should first fix this bug (by giving each TaskSetManager a unique name), in a separate PR, and then do the fix to this PR that you suggested, Mark. The other fix seems like it should be relatively simple. @markhamstra thoughts? Does that seem reasonable and do you buy the bug description above? |
erenavsarogullari
commented
Oct 4, 2016
Thanks @kayousterhout and @markhamstra. |
erenavsarogullari
commented
Oct 12, 2016
Hi @kayousterhout and @markhamstra, In the light of our previous discussion, i committed second patch as e126cd8. This PR' s changeset looks ok but it still needs unique |
`TaskSetManager` should have unique name to avoid adding duplicate ones to parent `Pool` via `SchedulableBuilder`. This problem has been surfaced with following discussion: [[PR: Avoid adding duplicate schedulables]](apache#15326) **Proposal** : There is 1x1 relationship between `stageAttemptId` and `TaskSetManager` so `taskSet.Id` covering both `stageId` and `stageAttemptId` looks to be used for uniqueness of `TaskSetManager` name instead of just `stageId`. **Current TaskSetManager Name** : `var name = "TaskSet_" + taskSet.stageId.toString` **Sample**: TaskSet_0 **Proposed TaskSetManager Name** : `val name = "TaskSet_" + taskSet.Id ` `// taskSet.Id = (stageId + "." + stageAttemptId)` **Sample** : TaskSet_0.0 Added new Unit Test. Author: erenavsarogullari <erenavsarogullari@gmail.com> Closesapache#15463 from erenavsarogullari/SPARK-17894.
erenavsarogullari
commented
Oct 25, 2016
Hi @kayousterhout and @markhamstra, Related PR #15463 is merged and this PR is ready for review. Also previous comments have been addressed with e126cd8ec51b11fed5ffaab376c6d4a451086cac. Thanks in advance. |
erenavsarogullari
commented
Oct 27, 2016
Kindly reminder :) |
`TaskSetManager` should have unique name to avoid adding duplicate ones to parent `Pool` via `SchedulableBuilder`. This problem has been surfaced with following discussion: [[PR: Avoid adding duplicate schedulables]](apache#15326) **Proposal** : There is 1x1 relationship between `stageAttemptId` and `TaskSetManager` so `taskSet.Id` covering both `stageId` and `stageAttemptId` looks to be used for uniqueness of `TaskSetManager` name instead of just `stageId`. **Current TaskSetManager Name** : `var name = "TaskSet_" + taskSet.stageId.toString` **Sample**: TaskSet_0 **Proposed TaskSetManager Name** : `val name = "TaskSet_" + taskSet.Id ` `// taskSet.Id = (stageId + "." + stageAttemptId)` **Sample** : TaskSet_0.0 Added new Unit Test. Author: erenavsarogullari <erenavsarogullari@gmail.com> Closesapache#15463 from erenavsarogullari/SPARK-17894.
erenavsarogullari
commented
Nov 3, 2016
Hi @kayousterhout and @markhamstra, |
kayousterhout
commented
Dec 16, 2016
@erenavsarogullari I looked at this again (sorry for the long delay), and it looks like you maintained the old behavior of last-added-wins. I thought from the discussion above, @markhamstra was ok with first-added-wins, which I think is more intuitive and consistent with other locations in the codebase. Did I miss something from above? |
`TaskSetManager` should have unique name to avoid adding duplicate ones to parent `Pool` via `SchedulableBuilder`. This problem has been surfaced with following discussion: [[PR: Avoid adding duplicate schedulables]](apache#15326) **Proposal** : There is 1x1 relationship between `stageAttemptId` and `TaskSetManager` so `taskSet.Id` covering both `stageId` and `stageAttemptId` looks to be used for uniqueness of `TaskSetManager` name instead of just `stageId`. **Current TaskSetManager Name** : `var name = "TaskSet_" + taskSet.stageId.toString` **Sample**: TaskSet_0 **Proposed TaskSetManager Name** : `val name = "TaskSet_" + taskSet.Id ` `// taskSet.Id = (stageId + "." + stageAttemptId)` **Sample** : TaskSet_0.0 Added new Unit Test. Author: erenavsarogullari <erenavsarogullari@gmail.com> Closesapache#15463 from erenavsarogullari/SPARK-17894.
kayousterhout
commented
Feb 7, 2017
@erenavsarogullari what's the status of this PR? |
kayousterhout
commented
Mar 24, 2017
@erenavsarogullari is this ready to be updated now that #16813 has been merged? |
erenavsarogullari
commented
Mar 24, 2017
@kayousterhout, thanks for querying this PR. |
erenavsarogullari
commented
Mar 29, 2017
Jenkins test this please |
erenavsarogullari
commented
Mar 30, 2017
Hi @kayousterhout and @markhamstra,
Thanks. |
kayousterhout
commented
Apr 2, 2017
Jenkins this is OK to test |
There was a problem hiding this comment.
When would this happen? (the same TSM getting added twice)
There was a problem hiding this comment.
Related fix aims to avoid adding duplicate schedulables (Pool and TSM). However, a new TSM is created for submitted TaskSet and duplicate TSM submission does not look an expected behaviour(although logic is robust enough for this case) so these test cases can be removed for clearer perspective.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
similar to the above -- when could this happen?
HyukjinKwon
commented
May 11, 2017
Hi @erenavsarogullari, is it still active? if so could you address the comments above? Otherwise, I would like to propose to close this. |
erenavsarogullari
commented
May 11, 2017
Hi @HyukjinKwon, thanks to follow this PR. I am busy for a while. Implementation is done and just last comments need to be addressed. I will address them as well asap. Thanks ;) |
erenavsarogullari
commented
Jun 8, 2017
Hi @HyukjinKwon, thanks for the following this PR again. This looks required but i am too busy for a while. Fix is already ready and will address the last comments asap. Sorry for delay again ;) |
HyukjinKwon
commented
Jun 8, 2017
I will take this out in the list. Thanks for your input. |
HyukjinKwon
commented
Jun 8, 2017
Gentle ping @kayousterhout. |
kayousterhout
commented
Jun 8, 2017
@HyukjinKwon what's the ping here for? It looks like I left some comments that @erenavsarogullari will address when he has time. |
I am sorry I misunderstood and thought it is almost (or already) ready. Will read the comments carefully next time. |
erenavsarogullari
commented
Jun 8, 2017
Hi @kayousterhout, |
erenavsarogullari
commented
Sep 11, 2017
Hi @kayousterhout, |
erenavsarogullari
commented
Jun 1, 2019
Jenkins test this please |
erenavsarogullari
commented
Jun 1, 2019
Hi All, |
erenavsarogullari
commented
Jun 2, 2019
retest this please |
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. |
What changes were proposed in this pull request?
If
spark.scheduler.allocation.filehas duplicate pools, all of them are created whenSparkContextis initialized but just one of them is used and the other ones look redundant. This causes redundant pool creation and needs to be fixed.Code to Reproduce :
fairscheduler-duplicate-pools.xml :
The following sample just shows two default and duplicate_pool1 but this also needs to be thought for N default and/or other duplicate pools.
Debug Screenshot :
The following screenshots show
Pool.schedulableQueue(ConcurrentLinkedQueue[Schedulable])has 4 pools asbut
Pool.schedulableNameToSchedulable(ConcurrentHashMap[String, Schedulable])hasdue to pool name as key so one of default and duplicate_pool1 look redundant and live in
Pool.schedulableQueue.
## How was this patch tested?Added new Unit Test case.