refactor: move index creation to onServerVersionChange#39253
refactor: move index creation to onServerVersionChange#39253
Conversation
- Remove createIndexes() call from BaseRaw constructor to avoid thundering herd of index creation on every model instantiation - Add ensureAllIndexes() in proxify to run createIndexes on all registered models - Call ensureAllIndexes() inside onServerVersionChange callback in xrun.ts so indexes are created only on first start or when server version (commit hash) changes - Reduces MongoDB load during normal restarts Made-with: Cursor
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fetch all settings in one MongoDB round-trip instead of streaming with forEach to reduce startup time when there is network latency. Made-with: Cursor
Made-with: Cursor
- Fetch all settings in one MongoDB round-trip with toArray() - Add setBulk() to CachedSettings to fill store without N ready listeners - Reduces startup time and memory churn during settings init Made-with: Cursor
…psertPermissions
- Build updateOne ops for all settings, run in batches of 500 via bulkWrite
- Use deleteMany for obsolete permissions instead of N deleteOne calls
- Keeps createSettingPermission for the settings.on('*') callback (single setting at runtime)
Made-with: Cursor
- Process apps in chunks of CONCURRENCY_LIMIT (4) with Promise.all - Each chunk runs canEnableApp + loadOne in parallel, then next chunk - Preserves app limit semantics by waiting for chunk before starting next Made-with: Cursor
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #39253 +/- ##
===========================================
+ Coverage 70.72% 70.87% +0.15%
===========================================
Files 3195 3208 +13
Lines 113108 113432 +324
Branches 20479 20515 +36
===========================================
+ Hits 79991 80398 +407
+ Misses 31067 30988 -79
+ Partials 2050 2046 -4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
- Added eslint-disable-next-line directive to permit await usage within a loop for better readability and maintainability of the code.
…ogic - Removed the setBulk method from CachedSettings to streamline the settings loading process. - Updated the initializeSettings function to set records individually instead of using bulk loading, enhancing clarity and maintainability.
Made-with: Cursor
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments