-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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(core): Update indexer controller to avoid TypeORM memory leak #2883
Conversation
❌ Deploy Preview for effervescent-donut-4977b2 failed.
|
it seems that e2e failed. |
Are you able to figure out why the e2e tests are failing? |
i am sorry, i am no much familiar typeorm(DB). maybe need. @carathorys help |
Hi! Anyway, I planned to take a look on it, and fix if there are any issues, but I can't do it before the end of the next week. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@michaelbromley Can you take a look on it please? I'm out of ideas now. |
i have tried to copy your code to my local, above test case also failed, revert these code all e2e cases works fine all cases in a test. file will run one by one |
@tianyingchun Did you tried to execute all the DefaultSearchPlugin tests, or just some of them? |
i have redefined- default search plugin because i have some customized fifelds. but i have copy all test cases relatated i try update you PR into my local |
Ok, hopefully I've found the issue: |
Unit tests are supposed to run source code, but not in your local environment? |
These are e2e tests, not unit tests, and in order to execute them on your code, first you need to build the packages :) |
…g the index build
…ata from database
it seems that search builder will lose |
The |
i have not migration above code to my project now,:), just found there missed variant featured assets :) |
and this PR have give us more performance improved? |
Actually, we have 4 channels with 4 different languages, and I've discovered some kind of strange memory issue earlier. EDIT: PS: |
nice, try it today :) it seems that we do not need to load below
|
and it seems that const affectedChannels = await this.getAllChannels(ctx, {
where: {
availableLanguageCodes: In(
product.translations.map((t) => t.languageCode)
),
},
}); @Column({ type: 'simple-array', nullable: true })
availableLanguageCodes: LanguageCode[]; in mysql it will store as |
Thanks for your work on this. I just tested locally and it works well. It also resolves #2907. |
ee2c177
into
vendure-ecommerce:master
Description
Previously I've tried to fix the search index plugin in order to avoid a memory leak I've tought was caused because of multiple channels. In order to fix it, I've changed the default indexer controller to use
queryBuilder
to fetch data from the database.Since that, I've discovered a bug in TypeORM (at least I think it's related to TypeORM), which causes the memory leak issue, and also discovered that the memory leak still exists in the indexer controller when I do a partial search index update, initiated from the admin-ui.
To avoid that, I've updated the indexer controller once again to use TypeORM repositories (instead of query builder), but instead of simply join tables, we have to explicitly say that the
relationLoadStrategy
should bequery
instead ofjoin
(which is the default behavior I think). This works properly as far as I can see, otherwise, if you would join multiple tables, TypeORM will eat all your memory instead of returning with the data you've requested.PS.: I think this TypeORM issue was introduced with TypeORM 0.3.20, as I didn't saw this issue in earlier versions of Vendure either, only since 2.2.x
Breaking changes
Everything should work as before.
Screenshots
You can add screenshots here if applicable.
Checklist
📌 Always:
👍 Most of the time: