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

Fix concurrency issue of Terraform provider cache (Cherry-pick of #21805) #21887

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

lilatomic
Copy link
Contributor

The Terraform provider cache is not concurrency safe.
The worst concurrency bug with the Terraform provider cache is a race condition when nonatomic moves result in another process capturing incorrect hashes in the lockfile which gets pulled into the Pants cache and then poisons it.

After lots of debugging and help from the community, we've determined that the best way forward is to isolate each module into its own Terraform cache. This prevents concurrent access to the Terraform cache.

One possible solution would have been to not cache during cache-unsafe operations. This is harder than it seems, because envvars can override user cache settings in Terraform RC files but they cannot unset it.

fixes #21804

The Terraform provider cache is not concurrency safe.
The worst concurrency bug with the Terraform provider cache is a race
condition when nonatomic moves result in another process capturing
incorrect hashes in the lockfile which gets pulled into the Pants cache
and then poisons it.

After [lots of debugging and help from the
community](https://chat.pantsbuild.org/t/26730983/i-m-finding-terraform-init-may-not-cache-stably-from-2-23-it#84153d7a-cedd-4600-838f-bd6ef99f6cc9),
we've determined that the best way forward is to isolate each module
into its own Terraform cache. This prevents concurrent access to the
Terraform cache.

One possible solution would have been to not cache during cache-unsafe
operations. This is harder than it seems, because envvars can override
user cache settings in Terraform RC files but they cannot _unset_ it.

fixes pantsbuild#21804
@lilatomic lilatomic added this to the 2.23.x milestone Jan 29, 2025
@lilatomic lilatomic added the category:bugfix Bug fixes for released features label Jan 29, 2025
@lilatomic lilatomic requested a review from tdyas January 29, 2025 16:07
@cburroughs cburroughs added the release-notes:not-required PR doesn't require mention in release notes label Jan 31, 2025
@cburroughs cburroughs enabled auto-merge (squash) January 31, 2025 14:46
@cburroughs cburroughs merged commit 47b5171 into pantsbuild:2.23.x Jan 31, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features release-notes:not-required PR doesn't require mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants