Skip to content

CBG-5414: Create indexes in mobile collection only if mobile collections is enabled#8351

Open
RIT3shSapata wants to merge 4 commits into
mainfrom
CBG-5414
Open

CBG-5414: Create indexes in mobile collection only if mobile collections is enabled#8351
RIT3shSapata wants to merge 4 commits into
mainfrom
CBG-5414

Conversation

@RIT3shSapata

@RIT3shSapata RIT3shSapata commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

CBG-5414

Describe your PR here...

  • Create indexes in mobile collections only when mobile collections is enabled
  • add test coverage for the same.

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Dependencies (if applicable)

  • Link upstream PRs
  • Update Go module dependencies when merged

Integration Tests

@RIT3shSapata RIT3shSapata requested a review from gregns1 June 10, 2026 09:39
Copilot AI review requested due to automatic review settings June 10, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts database index initialization to avoid creating _system._mobile collection indexes unless the system metadata collection feature is enabled for the database, reducing unnecessary index creation when the feature is off.

Changes:

  • Gate _system._mobile index initialization on UseSystemMobileMetadataCollection in buildCollectionIndexData.
  • Expand TestBuildCollectionIndexData to cover enabled/disabled combinations for default and named-collection configs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
rest/database_init_manager.go Conditionally includes _system._mobile in the collection/index initialization set based on config.
rest/database_init_manager_test.go Adds/updates unit tests for buildCollectionIndexData under enabled/disabled system metadata collection scenarios.

Comment thread rest/database_init_manager.go
Comment thread rest/database_init_manager.go Outdated
Comment thread rest/database_init_manager_test.go Outdated
Comment on lines 520 to 525
name: "implicit default collection with mobile collection enabled",
config: &DatabaseConfig{
DbConfig: DbConfig{
Scopes: nil,
Scopes: nil,
UseSystemMobileMetadataCollection: base.Ptr(true),
},
Comment thread rest/database_init_manager_test.go Outdated
@adamcfraser adamcfraser self-assigned this Jun 10, 2026
Comment thread rest/database_init_manager.go
- use startup/bootstrap config to check if systemMetadataCollection is enabled or not
- add test coverage

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@gregns1 gregns1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also pass down whether migration is complete or not. Obviously if the _default collection is in use for the db we still need indexes created on it. But if its not and migration is set to complete on the metadata store, we should be able to avoid making metadata indexes on the default given this won't be in use at all for this scenario.

To do this we can maybe slightly change this code here

if dual, isDual := contextOptions.MetadataStore.(*base.MetadataStore); isDual {
to set metadataMigrationComplete = dual.MigrationComplete() in this block and pass down this into InitializeDatabaseWithStatusCallback then buildCollectionIndexData?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread rest/database_init_manager.go Outdated
Comment thread rest/database_init_manager_test.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread rest/admin_api.go
Comment on lines 495 to +499
useLegacySyncDocsIndex := h.db.UseLegacySyncDocsIndex()
if req.SeparatePrincipalIndexes != nil {
useLegacySyncDocsIndex = !(*req.SeparatePrincipalIndexes)
}
done, err := h.server.DatabaseInitManager.InitializeDatabaseWithStatusCallback(h.ctx(), h.server.initialStartupConfig, &newDbConfig, statusCallback, useLegacySyncDocsIndex)
done, err := h.server.DatabaseInitManager.InitializeDatabaseWithStatusCallback(h.ctx(), h.server.initialStartupConfig, &newDbConfig, statusCallback, useLegacySyncDocsIndex, false)
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.

4 participants