Skip to content

refactor: move index creation to onServerVersionChange#39253

Draft
ggazzo wants to merge 9 commits intodevelopfrom
chore/startup
Draft

refactor: move index creation to onServerVersionChange#39253
ggazzo wants to merge 9 commits intodevelopfrom
chore/startup

Conversation

@ggazzo
Copy link
Member

@ggazzo ggazzo commented Mar 2, 2026

  • 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

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

- 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
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 2, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

⚠️ No Changeset found

Latest commit: c9d7fec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

ggazzo added 5 commits March 2, 2026 15:03
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
- 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
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.89%. Comparing base (e6de8b7) to head (c9d7fec).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39253      +/-   ##
===========================================
+ Coverage    70.72%   70.89%   +0.17%     
===========================================
  Files         3195     3208      +13     
  Lines       113108   113448     +340     
  Branches     20479    20527      +48     
===========================================
+ Hits         79991    80427     +436     
+ Misses       31067    30973      -94     
+ Partials      2050     2048       -2     
Flag Coverage Δ
unit 71.58% <53.84%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ggazzo added 3 commits March 2, 2026 16:27
- Added eslint-disable-next-line directive to permit await usage within a loop for better readability and maintainability of the code.
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 this pull request may close these issues.

1 participant