Skip to content

Fix deadlocks in Staging Areas.#13684

Merged
caisq merged 1 commit intotensorflow:masterfrom
sjperkins:fix-staging-area-race-deadlocks
Oct 13, 2017
Merged

Fix deadlocks in Staging Areas.#13684
caisq merged 1 commit intotensorflow:masterfrom
sjperkins:fix-staging-area-race-deadlocks

Conversation

@sjperkins
Copy link
Copy Markdown
Contributor

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.

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.
@tensorflow-jenkins
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@sjperkins
Copy link
Copy Markdown
Contributor Author

With reference to #9686 and #10528

@sjperkins sjperkins changed the title Fix possible deadlocks in Staging Areas. Fix deadlocks in Staging Areas. Oct 13, 2017
@caisq caisq requested review from ebrevdo and removed request for ebrevdo October 13, 2017 14:24
@caisq
Copy link
Copy Markdown
Contributor

caisq commented Oct 13, 2017

cc @ekelsen

@caisq
Copy link
Copy Markdown
Contributor

caisq commented Oct 13, 2017

@ekelsen, can you take a look at this PR?

@caisq
Copy link
Copy Markdown
Contributor

caisq commented Oct 13, 2017

@tensorflow-jenkins test this please

Copy link
Copy Markdown
Contributor

@ekelsen ekelsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this.

@caisq caisq merged commit 3564997 into tensorflow:master Oct 13, 2017
@sjperkins sjperkins deleted the fix-staging-area-race-deadlocks branch November 30, 2017 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants