@@ -195,15 +195,15 @@ For sharded clusters, the index build occurs only on shards
195
195
containing data for the collection being indexed.
196
196
197
197
.. warning::
198
-
199
- Avoid dropping any index on a collection while an index is being
198
+
199
+ Avoid dropping any index on a collection while an index is being
200
200
replicated on the secondaries.
201
-
202
- If you attempt to drop an index from a collection on a :term:`primary`
203
- node while the collection has a background index building on the
204
- :term:`secondary` nodes, the two indexing operations will conflict
205
- with each other.
206
-
201
+
202
+ If you attempt to drop an index from a collection on a :term:`primary`
203
+ node while the collection has a background index building on the
204
+ :term:`secondary` nodes, the two indexing operations will conflict
205
+ with each other.
206
+
207
207
As a result, reads will be halted across all namespaces and
208
208
replication will halt until the background index build completes.
209
209
When the build finishes the dropIndex action will execute, then
@@ -247,16 +247,26 @@ Build Failure and Recovery
247
247
Interrupted Index Builds on a Primary ``mongod``
248
248
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
249
249
250
- If the primary :binary:`~bin.mongod` shuts down during the index build,
251
- the build progress is lost. The :binary:`~bin.mongod` automatically
252
- recovers the index build and restarts it from the beginning.
250
+ Starting in MongoDB 5.0, if the primary :binary:`~bin.mongod` shuts
251
+ down cleanly during the index build and the
252
+ :ref:`commitQuorum <createIndexes-cmd-commitQuorum>` is set to the
253
+ default ``votingMembers``, then the index build progress is saved to
254
+ disk. The :binary:`~bin.mongod` automatically recovers the index build
255
+ when it is restarted and continues from the saved checkpoint. In earler
256
+ versions, if the index build was interrupted it had to be restarted
257
+ from the beginning.
253
258
254
259
Interrupted Index Builds on a Secondary ``mongod``
255
260
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
256
261
257
- If a secondary shuts down during the index build, the index build job is
258
- persisted. Restarting the :binary:`~bin.mongod` automatically recovers
259
- the index build and restarts it from the beginning.
262
+ Starting in MongoDB 5.0, if a secondary :binary:`~bin.mongod` shuts
263
+ down cleanly during the index build and the
264
+ :ref:`commitQuorum <createIndexes-cmd-commitQuorum>` is set to the
265
+ default ``votingMembers``, then the index build progress is saved to
266
+ disk. The :binary:`~bin.mongod` automatically recovers the index build
267
+ when it is restarted and continues from the saved checkpoint. In earler
268
+ versions, if the index build was interrupted it had to be restarted
269
+ from the beginning.
260
270
261
271
Prior to MongoDB 4.4, the startup process stalls behind any recovered
262
272
index builds. The secondary could fall out of sync with the replica set
@@ -282,6 +292,12 @@ the index build.
282
292
Rollbacks during Build Process
283
293
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284
294
295
+ Starting in MongoDB 5.0, if a node is rolled back to a prior state
296
+ during the index build, the index build progress is saved to disk. If
297
+ there is still work to be done when the rollback concludes, the
298
+ :binary:`~bin.mongod` automatically recovers the index build and
299
+ continues from the saved checkpoint.
300
+
285
301
Starting in version 4.4, MongoDB can pause an in-progress
286
302
index build to perform a :doc:`rollback </core/replica-set-rollbacks>`.
287
303
@@ -341,6 +357,20 @@ filter the current operations for index creation operations, see
341
357
The :data:`~currentOp.msg` field includes a percentage-complete
342
358
measurement of the current stage in the index build process.
343
359
360
+ Observe Stopped and Resumed Index Builds in the Logs
361
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362
+
363
+ While an index is being built, progress is written to the
364
+ :doc:`MongoDB log</reference/log-messages>`. If an index build is
365
+ stopped and resumed there will be log messages with fields like these:
366
+
367
+ .. code-block:: sh
368
+ :copyable: false
369
+
370
+ "msg":"Index build: wrote resumable state to disk",
371
+
372
+ "msg":"Found index from unfinished build",
373
+
344
374
Terminate In Progress Index Builds
345
375
----------------------------------
346
376
0 commit comments