Skip to content
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

IndexInfo does not expose background option of the index #4760

Closed
debugmaster opened this issue Aug 5, 2024 · 3 comments
Closed

IndexInfo does not expose background option of the index #4760

debugmaster opened this issue Aug 5, 2024 · 3 comments
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@debugmaster
Copy link

While working with MongoOperations and IndexOperations, and it hard to validate when an index has been created with background or not.

Mongo version: 7.0.12
SpringData MongoDB version: 4.2.4

Simple Java Code:

IndexDefinition definition = new Index()
        .on("field", Sort.Direction.ASC)
        .background();
mongoOperations.indexOps(IndexedClass.class).ensureIndex(indexDefinition);

mongoOperations.indexOps(IndexedClass.class).getIndexInfo();
// No way to validate whether background option exists on the index

Looking at Mongo, it seems to keep track of it:

db.getCollection('indexedClass').getIndexes()
[
  { v: 2, key: { _id: 1 }, name: '_id_' },
  { v: 2, key: { field: 1 }, name: 'field_1', background: true }
]

Please include background property to IndexInfo

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 5, 2024
@christophstrobl christophstrobl added type: enhancement A general enhancement status: ideal-for-contribution An issue that a contributor can help us with and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 5, 2024
@christophstrobl
Copy link
Member

Thank you @debugmaster for getting in touch - if you've got time to submit a PR we'd be happy to review the changes.

@marcingrzejszczak
Copy link
Contributor

For future reference. This is the section of the mongodb documentation that talks about foreground and background index builds.

@marcingrzejszczak
Copy link
Contributor

After reading through this part of the Mongo docs it seems that since version 4.2 the background index property has no effect.

Deprecated: In MongoDB 4.0 and earlier, users could control whether to build indexes in the foreground (blocking) or background (non-blocking, but less efficient) using the background option.

class Person
  include Mongoid::Document
  field :ssn
  index({ ssn: 1 }, { unique: true, background: true })
end

The default value of background is controlled by Mongoid's background_indexing configuration option.

The background option has no effect as of MongoDB 4.2.

Closing this issue as invalid.

@marcingrzejszczak marcingrzejszczak closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
@marcingrzejszczak marcingrzejszczak added status: invalid An issue that we don't feel is valid and removed status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement labels Sep 11, 2024
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: invalid An issue that we don't feel is valid labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

5 participants