Navigation Menu

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

[BUG] Version error and memory leak #8040

Closed
LaurensRietveld opened this issue Aug 1, 2019 · 3 comments · Fixed by #8048
Closed

[BUG] Version error and memory leak #8040

LaurensRietveld opened this issue Aug 1, 2019 · 3 comments · Fixed by #8048
Milestone

Comments

@LaurensRietveld
Copy link

Do you want to request a feature or report a bug?
Bug

What happens:

  • After recently updating mongoose, we've experienced a memory leak.
  • When saving a document, a version-error is created and saved to this.$__.$versionError
  • When creating this version error it runs a captureStacktrace command. Capturing the stack means references to it's stack (for us that included CLS, requests, etc) are retained. This is related to this nodejs issue
  • As a result, the errors and their stack are not garbage collected. With many save operations this would cause our process to run out of memory

Why this didnt happen before

  • In this commit the versionerror is stored in this.$__.$versionError instead of options.$versionError
  • The options object is cleaned up after a save (see here). The this.$__.$versionError however isnt

Workaround

  • Using a post-save hook that deletes this.$__.$versionError

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose: 5.6.3
node: v10.16.0
mongo: 3.4.1

cc @thombohlk

@vkarpov15
Copy link
Collaborator

Fix will be in 5.6.9 within the next 48 hours 👍

@LaurensRietveld
Copy link
Author

LaurensRietveld commented Nov 12, 2019

@vkarpov15 @Fonger : This is still an issue in 5.7.5. We still experience a memory leak when we remove our post-save hook that deletes the versionError manually.
It seems the above fix contains a typo. delete this.$__.versionError; should be delete this.$__.$versionError;

@Fonger
Copy link
Contributor

Fonger commented Nov 12, 2019

Sorry it's my fault. A revised PR has been submitted #8326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants