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

Delay Schema Caching Until Resource Operations #784

Closed
bflad opened this issue Jun 21, 2023 · 1 comment · Fixed by #785
Closed

Delay Schema Caching Until Resource Operations #784

bflad opened this issue Jun 21, 2023 · 1 comment · Fixed by #785
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Jun 21, 2023

Module version

v1.3.1

Description

Currently, this Go module will cache data source and managed resource (collectively called "resource" from now on) schemas when the GetProviderSchema RPC is called. This caching was introduced to prevent the multiple RPCs associated with a single resource from continually invoking the Schema method for no benefit as by Terraform's definition, schemas must be static. For large providers, this is very problematic as it will actively keep unused schema information that is likely not needed again in memory. Providers do not have an opt-out for this framework behavior.

Proposal

Rather than caching resource schemas during GetProviderSchema RPC, which in turn will keep all schemas in memory, only perform the caching when another resource-based operation RPC occurs. This should ensure that:

  • Go garbage collection can occur after the GetProviderSchema RPC
  • Actively used schemas still receive the slight performance benefit of caching rather than repeatedly invoking the Schema method

It'll be worth exploring with upstream if the schema fetching can be split across RPCs to prevent a large allocation for GetProviderSchema RPC response.

References

@bflad bflad added the enhancement New feature or request label Jun 21, 2023
@bflad bflad self-assigned this Jun 21, 2023
@bflad bflad added bug Something isn't working and removed enhancement New feature or request labels Jun 21, 2023
@bflad bflad added this to the v1.4.0 milestone Jun 21, 2023
bflad added a commit that referenced this issue Jun 23, 2023
bflad added a commit that referenced this issue Jun 26, 2023
@bflad bflad modified the milestones: v1.4.0, v1.3.2 Jun 28, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
1 participant