Skip to content

Commit 27122e9

Browse files
MONGOID-5318 Clarify that index background / background_indexing options are deprecated as of MongoDB 4.2 (#5249)
Co-authored-by: shields <[email protected]>
1 parent 2b8970f commit 27122e9

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

docs/reference/configuration.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@ for details on driver options.
260260
# if the database name is not explicitly defined. (default: nil)
261261
app_name: MyApplicationName
262262

263-
# Create indexes in background by default. (default: false)
264-
background_indexing: false
265-
266263
# Mark belongs_to associations as required by default, so that saving a
267264
# model with a missing belongs_to association will trigger a validation
268265
# error. (default: true)
@@ -420,6 +417,10 @@ for details on driver options.
420417
# (default: false)
421418
use_utc: false
422419

420+
# (Deprecated) In MongoDB 4.0 and earlier, set whether to create
421+
# indexes in the background by default. (default: false)
422+
background_indexing: false
423+
423424
ERb Preprocessing
424425
=================
425426

docs/reference/indexes.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ Indexes can be sparse:
6161
index({ ssn: -1 }, { sparse: true })
6262
end
6363

64-
Indexes can be specified to be created in the background in cases where
65-
the collection is large and index creation may take a long time:
64+
*Deprecated:* In MongoDB 4.0 and earlier, users could control whether to build indexes
65+
in the foreground (blocking) or background (non-blocking, but less efficient) using the
66+
``background`` option.
6667

6768
.. code-block:: ruby
6869

@@ -72,9 +73,11 @@ the collection is large and index creation may take a long time:
7273
index({ ssn: 1 }, { unique: true, background: true })
7374
end
7475

75-
If the ``background_indexing`` :ref:`configuration option
76-
<configuration-options>` is true, the indexes are created in the background
77-
unless the ``background: false`` option is provided.
76+
The default value of ``background`` is controlled by Mongoid's
77+
``background_indexing`` :ref:`configuration option <configuration-options>`.
78+
79+
The ``background`` option has `no effect as of MongoDB 4.2
80+
<https://www.mongodb.com/docs/manual/core/index-creation/#comparison-to-foreground-and-background-builds>`_.
7881

7982
*Deprecated:* When using MongoDB 2.6, you can drop the duplicate entries
8083
for unique indexes that are defined for a column that might

lib/mongoid/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module Config
2323
# database name is not explicitly defined.
2424
option :app_name, default: nil
2525

26-
# Create indexes in background by default.
26+
# (Deprecated) In MongoDB 4.0 and earlier, set whether to create
27+
# indexes in the background by default. (default: false)
2728
option :background_indexing, default: false
2829

2930
# Mark belongs_to associations as required by default, so that saving a

lib/rails/generators/mongoid/config/templates/mongoid.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ development:
120120
# database name is not explicitly defined. (default: nil)
121121
# app_name: MyApplicationName
122122

123-
# Create indexes in background by default. (default: false)
124-
# background_indexing: false
125-
126123
# Mark belongs_to associations as required by default, so that saving a
127124
# model with a missing belongs_to association will trigger a validation
128125
# error. (default: true)
@@ -167,6 +164,10 @@ development:
167164
# (default: false)
168165
# use_utc: false
169166

167+
# (Deprecated) In MongoDB 4.0 and earlier, set whether to create
168+
# indexes in the background by default. (default: false)
169+
# background_indexing: false
170+
170171
test:
171172
clients:
172173
default:

0 commit comments

Comments
 (0)