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: copy RawConfigs to avoid races #1454

Merged
merged 2 commits into from
Apr 9, 2015
Merged

terraform: copy RawConfigs to avoid races #1454

merged 2 commits into from
Apr 9, 2015

Conversation

mitchellh
Copy link
Contributor

Fixes #1416 probably

This adds a Copy method to *config.RawConfig that performs a parallel-safe copy. The reason this is necessary is because *config.RawConfig.Interpolate has a slight race in the way it reads from and writes to r.config at the same time.

While I couldn't come up with a test case to prove it, I'm very confident this is what caused #1416. The key there being that in his repro, one of them isn't interpolated at all. I think this is because it wrote r.config properly but then another interpolation overwrote it with a raw version, and interpolation didnt' see those values.

I can't be 100% sure. I couldn't reproduce the bug, but looking over the code this was the only shared state that I could find anywhere.

result, err := NewRawConfig(r.Raw)
if err != nil {
panic("copy failed: " + err.Error())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I panic here because if the *RawConfig was made once, it shouldn't fail ever again. It is a pure function in that way.

mitchellh added a commit that referenced this pull request Apr 9, 2015
terraform: copy RawConfigs to avoid races
@mitchellh mitchellh merged commit 8083098 into master Apr 9, 2015
@mitchellh mitchellh deleted the f-copy-config branch April 9, 2015 16:33
@phinze
Copy link
Contributor

phinze commented Apr 9, 2015

🐎 👍

@ghost
Copy link

ghost commented May 3, 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 3, 2020
This pull request was closed.
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.

inconsistent count interpolation
2 participants