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

core: fix deadlock when dependable node replaced with non-dependable one #2968

Merged
merged 3 commits into from
Aug 11, 2015

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Aug 10, 2015

In #2884, Terraform would hang on graphs with an orphaned resource
depended on an orphaned module.

This is because orphan module nodes (which are dependable) were getting
expanded (replaced) with GraphNodeBasicSubgraph nodes (which are not
dependable).

The old graph.Replace() code resulted in GraphNodeBasicSubgraph being
entered into the lookaside table, even though it is not dependable.

This resulted in an untraversable edge in the graph, so the graph would
hang and wait forever.

Now, we remove entries from the lookaside table when a dependable node
is being replaced with a non-dependable node. This means we lose an
edge, but we can move forward. It's probably never correct to be
replacing depenable nodes with non-dependable ones, but this tweak
seemed preferable to tossing a panic in there.

@phinze phinze force-pushed the b-orphan-module-deadlock branch 2 times, most recently from 0e24e99 to 6c472df Compare August 10, 2015 20:41
phinze added 3 commits August 10, 2015 15:50
Helps to flush out deadlocks in the dependency graph
In #2884, Terraform would hang on graphs with an orphaned resource
depended on an orphaned module.

This is because orphan module nodes (which are dependable) were getting
expanded (replaced) with GraphNodeBasicSubgraph nodes (which are _not_
dependable).

The old `graph.Replace()` code resulted in GraphNodeBasicSubgraph being
entered into the lookaside table, even though it is not dependable.

This resulted in an untraversable edge in the graph, so the graph would
hang and wait forever.

Now, we remove entries from the lookaside table when a dependable node
is being replaced with a non-dependable node. This means we lose an
edge, but we can move forward. It's ~probably~ never correct to be
replacing depenable nodes with non-dependable ones, but this tweak
seemed preferable to tossing a panic in there.
@phinze phinze force-pushed the b-orphan-module-deadlock branch from 6c472df to 52c4bfb Compare August 10, 2015 20:50
}
}
log.Printf("[DEBUG] vertex %s, got dep: %s",
VertexName(v), VertexName(deps[i]))
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this debugging.

@mitchellh
Copy link
Contributor

LGTM!

@mitchellh
Copy link
Contributor

(Minor nitpicks, but the core stuff is good)

phinze added a commit that referenced this pull request Aug 11, 2015
core: fix deadlock when dependable node replaced with non-dependable one
@phinze phinze merged commit 88dcb24 into master Aug 11, 2015
@phinze phinze deleted the b-orphan-module-deadlock branch August 11, 2015 14:56
@ghost
Copy link

ghost commented May 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants