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

usage reporting: fix memory leak #7000

Merged
merged 1 commit into from Oct 7, 2022

Conversation

glasser
Copy link
Member

@glasser glasser commented Oct 7, 2022

A data structure in the usage reporting plugin would get a new entry each time the server's schema changed. Old entries would never be deleted, though their values would be shrunk to a minimum size.

It seems that this was not good enough and is producing notable memory leaks for some folks. So let's fix it!

The reason for the old behavior was to be really careful to never write to a report that may have already been taken out of the map and sent. Previously this was accomplished by having the main entry in the map never change. Now this is accomplished by making sure that we never write to the report any later than immediately (and synchronously) after we pull it out of the map.

Fixes #6983. Backport from #6998.

A data structure in the usage reporting plugin would get a new entry
each time the server's schema changed. Old entries would never be
deleted, though their values would be shrunk to a minimum size.

It seems that this was not good enough and is producing notable memory
leaks for some folks. So let's fix it!

The reason for the old behavior was to be really careful to never write
to a report that may have already been taken out of the map and sent.
Previously this was accomplished by having the main entry in the map
never change. Now this is accomplished by making sure that we never
write to the report any later than immediately (and synchronously) after
we pull it out of the map.

Fixes #6983. Backport from #6998.
@netlify
Copy link

netlify bot commented Oct 7, 2022

Deploy Preview for apollo-server-docs canceled.

Name Link
🔨 Latest commit 97e2882
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/6340a1f5f811550008b7bc2d

@glasser glasser enabled auto-merge (squash) October 7, 2022 22:02
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 7, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 97e2882:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration
Apollo Server Issue #6983

@glasser glasser merged commit cd31e33 into main Oct 7, 2022
@glasser glasser deleted the glasser/backport-usage-reporting-leak branch October 7, 2022 22:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
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.

Possible memory leak in ApolloServerPluginUsageReporting
1 participant