Skip to content

Commit 336acda

Browse files
mungitoperritojeff-allen-mongo
authored andcommitted
DOCSP-7693 resumable index build
1 parent f1bedb1 commit 336acda

File tree

4 files changed

+65
-16
lines changed

4 files changed

+65
-16
lines changed

source/core/index-creation.txt

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ For sharded clusters, the index build occurs only on shards
195195
containing data for the collection being indexed.
196196

197197
.. 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
200200
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+
207207
As a result, reads will be halted across all namespaces and
208208
replication will halt until the background index build completes.
209209
When the build finishes the dropIndex action will execute, then
@@ -247,16 +247,26 @@ Build Failure and Recovery
247247
Interrupted Index Builds on a Primary ``mongod``
248248
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
249249

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.
253258

254259
Interrupted Index Builds on a Secondary ``mongod``
255260
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
256261

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.
260270

261271
Prior to MongoDB 4.4, the startup process stalls behind any recovered
262272
index builds. The secondary could fall out of sync with the replica set
@@ -282,6 +292,12 @@ the index build.
282292
Rollbacks during Build Process
283293
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284294

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+
285301
Starting in version 4.4, MongoDB can pause an in-progress
286302
index build to perform a :doc:`rollback </core/replica-set-rollbacks>`.
287303

@@ -341,6 +357,20 @@ filter the current operations for index creation operations, see
341357
The :data:`~currentOp.msg` field includes a percentage-complete
342358
measurement of the current stage in the index build process.
343359

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+
344374
Terminate In Progress Index Builds
345375
----------------------------------
346376

source/reference/command/createIndexes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ Definition
9797
marks the ``indexes`` as ready. A "voting" member is any
9898
replica set member where :rsconf:`members[n].votes` is greater
9999
than ``0``.
100+
101+
Starting in MongoDB v5.0 it is possible to resume some
102+
:ref:`interupted index builds<index-operations-build-failure>`
103+
when the commit quorum is set to ``"votingMembers"``.
100104

101105
Supports the following values:
102106

source/reference/command/setIndexCommitQuorum.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ setIndexCommitQuorum
7474
must report a successful :ref:`index build
7575
<index-operations-replicated-build>` before the primary
7676
marks the ``indexes`` as ready. A "voting" member is any
77-
replica set member where :rsconf:`members[n].votes` is greater
78-
than ``0``.
77+
replica set member where :rsconf:`members[n].votes` is
78+
greater than ``0``.
79+
80+
Starting in MongoDB v5.0 it is possible to resume some
81+
:ref:`interupted index builds<index-operations-build-failure>`
82+
when the commit quorum is set to ``"votingMembers"``.
7983

8084
Supports the following values:
8185

source/release-notes/5.0.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,20 @@ Drivers
106106
Indexes
107107
-------
108108

109+
New Error Messages
110+
~~~~~~~~~~~~~~~~~~
111+
109112
The :method:`db.collection.createIndex()` and :method:`db.collection.createIndexes()`
110113
operations have new error messages when options are specified incorrectly.
111114

115+
Interrupted Index Builds
116+
~~~~~~~~~~~~~~~~~~~~~~~~
117+
118+
If a node in a replica set is cleanly shutdown or rolls back during an
119+
index build, the index build progress is now
120+
:ref:`saved to disk<index-operations-build-failure>`. When the server
121+
restarts, index creation resumes from the saved position.
122+
112123
.. _5.0-rel-notes-removed-commands:
113124

114125
Removed Commands

0 commit comments

Comments
 (0)