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

terraform: share graph walker's variables lock w/ interpolater #5772

Merged
merged 1 commit into from
Mar 21, 2016

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Mar 21, 2016

The ContextGraphWalker struct includes a lock that's passed down to
BuiltinEvalContext and guards access to interpolation variables as
they're written using SetVariables.

The likely problem being expressed in #5733 is that the same map
reference is also passed down to the Interpolater.Variables field, which
is used for variable lookup.

Here, we plumb the same lock we're using to guard access for writes down
and acquire it before doing variable reads as well. It's not as fine
grained as perhaps it could be, but all the context tests pass and I
believe this should address #5733.

The ContextGraphWalker struct includes a lock that's passed down to
BuiltinEvalContext and guards access to interpolation variables as
they're written using SetVariables.

The likely problem being expressed in #5733 is that the same map
reference is also passed down to the Interpolater.Variables field, which
is used for variable lookup.

Here, we plumb the same lock we're using to guard access for writes down
and acquire it before doing variable reads as well. It's not as fine
grained as perhaps it could be, but all the context tests pass and I
believe this should address #5733.
@@ -273,6 +274,8 @@ func (i *Interpolater) valueUserVar(
n string,
v *config.UserVariable,
result map[string]ast.Variable) error {
i.VariablesLock.Lock()
defer i.VariablesLock.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably don't need to defer here, just unlock right below the next line.

@mitchellh
Copy link
Contributor

One comment, then go for merge.

@phinze phinze force-pushed the phinze/var-concurrent-map-race branch from db06574 to 024dcc9 Compare March 21, 2016 23:22
@phinze
Copy link
Contributor Author

phinze commented Mar 21, 2016

There's a range over i.Variables on line 298 I thought I needed to cover as well?

@mitchellh
Copy link
Contributor

Oh I missed it. Sounds good.

phinze added a commit that referenced this pull request Mar 21, 2016
terraform: share graph walker's variables lock w/ interpolater
@phinze phinze merged commit 7efc8b2 into master Mar 21, 2016
@phinze phinze deleted the phinze/var-concurrent-map-race branch March 21, 2016 23:29
@ghost
Copy link

ghost commented Apr 27, 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 Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants