Fix deadlocks in Staging Areas.#13684
Merged
caisq merged 1 commit intotensorflow:masterfrom Oct 13, 2017
Merged
Conversation
Previously, `notify_one` was used to notify inserters and removers waiting to insert and remove elements into the Staging Areas. This could result in deadlock when many removers where waiting for different keys in the case of the MapStagingArea, or were waiting on either peeks or get operations in the StagingArea. For example, if two removers were waiting for keys 2 and 3 in a MapStaging Area respectively, and 2 was inserted but only 3's remover was notified, it is possible that 2's remover would never be notified resulting in deadlock. Thus, both should be notified. Similarly in the case of the StagingArea with a remover and a peeker wanting to remove the last element and peek at a specific element respectively, it is not clear which one should be notified due to an insert. Thus, both should be notified. Additionally, all inserters are now notified when an element is removed. Consider the case where two inserters are waiting to small elements into the Staging Area and a remover removes a single large element. As there may be space for both insertion elements, both inserters should be notified.
Collaborator
|
Can one of the admins verify this patch? |
Contributor
Author
Contributor
|
cc @ekelsen |
Contributor
|
@ekelsen, can you take a look at this PR? |
Contributor
|
@tensorflow-jenkins test this please |
ekelsen
approved these changes
Oct 13, 2017
Contributor
ekelsen
left a comment
There was a problem hiding this comment.
Thanks for catching this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
notify_onewas used to notify inserters and removers waiting to insert and remove elements into the Staging Areas. This could result in deadlock when many removers where waiting fordifferent keys in the case of the MapStagingArea, or were waiting on either peeks or get operations in the StagingArea.
For example, if two removers were waiting for keys 2 and 3 in a MapStaging Area respectively, and 2 was inserted but only 3's remover was notified, it is possible that 2's remover would never be notified resulting in deadlock. Thus, both should be notified.
Similarly in the case of the StagingArea with a remover and a peeker wanting to remove the last element and peek at a specific element respectively, it is not clear which one should be notified due to
an insert. Thus, both should be notified.
Additionally, all inserters are now notified when an element is removed. Consider the case where two inserters are waiting to small elements into the Staging Area and a remover removes a single large element. As there may be space for both insertion elements, both inserters should be notified.