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 mongo OOM during sync #42140
Fix mongo OOM during sync #42140
Conversation
@@ -70,7 +70,7 @@ | |||
skip (.skip skip) | |||
batch-size (.batchSize (int batch-size)) | |||
sort-criteria (.sort (mongo.conversion/to-document (ordered-map/ordered-map sort-criteria)))) | |||
(mapv #(mongo.conversion/from-document % opts)))) | |||
(map #(mongo.conversion/from-document % opts)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are more places here that use mapv
. My gut says we should convert them all. Should we? @lbrdnk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open tech debt issue tracking this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed we don't have any behavior test here. I can add it later if we want to. but this PR should fix the escalation only.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -70,7 +70,7 @@ | |||
skip (.skip skip) | |||
batch-size (.batchSize (int batch-size)) | |||
sort-criteria (.sort (mongo.conversion/to-document (ordered-map/ordered-map sort-criteria)))) | |||
(mapv #(mongo.conversion/from-document % opts)))) | |||
(map #(mongo.conversion/from-document % opts)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open tech debt issue tracking this.
@qnkhuat Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
Co-authored-by: Ngoc Khuat <[email protected]>
(is (= clojure.lang.LazySeq | ||
(type (mongo.util/do-find (mongo.util/collection db "venues"))))))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than coding to a concrete type, and assuming that it hasn't been realized, you could instead assert that realized?
is false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yea that'd be nicer.
Fixes #42133
The big memory usage comes from the
mongo.util/do-find
method, which return a vector. We should use a lazy seq instead.This is a regression and introduced by #38017
Here is a script to demonstrate memory usage before and after the changes.
Before:
After
You can see that using lazy seq the memory usage barely increases at all.