Skip to content
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

Fixed deadlock with SetNodeInfo #188

Merged
merged 1 commit into from
Apr 16, 2021
Merged

Fixed deadlock with SetNodeInfo #188

merged 1 commit into from
Apr 16, 2021

Conversation

Kenwes13
Copy link
Contributor

Premise

When the SetNodeInfo's nodes n and oldNode are the same pointer there is a deadlock because the SetNodeInfo holds node n's mutex and defers the release. However, in the SetNodeInfo it calls GetInfo on the oldNode and GetInfo waits for the mutex to be released by SetNodeInfo.

Changes

  • When SetNodeInfo is called it first checks if the pointers are the same, and if they are it returns right away.

When the SetNodeInfo nodes n and oldNode are the same pointer there is a deadlock because the SetNodeInfo holds node n's mutex and defers the release. However, in the SetNodeInfo it calls GetInfo on the oldNode and GetInfo waits for the mutex to be released by SetNodeInfo.
@@ -595,6 +595,9 @@ func (n *Node) getTime(uri string) float64 {

func (n *Node) SetNodeInfo(oldNode *Node) {
// Copy timers and size to new map from oldNode
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good.
Maybe move this comment below the equality check.

@peterlimg peterlimg merged commit cad6d27 into master Apr 16, 2021
@platsko platsko deleted the vc-deadlock-node branch May 5, 2021 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants