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

plugin: Introduce explicit locking on the root runner operations #2115

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Sep 8, 2024

Follow up of #2094

The bug in #2094 was fixed by #2096, but the problem of race conditions being prone to occur because the root runner is shared by multiple goroutines remains. Ideally, "Do not communicate by sharing memory; instead, share memory by communicating", but this would require significant design changes.

As a compromise, this PR changes the plugin API to acquire an explicit lock when performing operations on the root runner. This makes race conditions less likely to occur if side-effective operations are unintentionally introduced into the Runner API.

On the other hand, if multiple plugins perform frequent operations on the root runner, there is a risk of performance degradation. At least in most current cases, this is called only once during the initialization phase to obtain the contents of the provider block, so I suspect this problem will not be apparent.

In the future, we will need to redesign the API in conjunction with terraform-linters/tflint-plugin-sdk#193.

@wata727 wata727 merged commit 2d56e0d into master Sep 14, 2024
14 checks passed
@wata727 wata727 deleted the explicit_locking_on_the_root_runner branch September 14, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant