Skip to content

Commit d04f90e

Browse files
committed
DOCS-12032,DOCS-11942: index key limit fcv4.2
1 parent 5b0ebd0 commit d04f90e

11 files changed

+98
-37
lines changed

source/core/document.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ existing user document.
9595
Field Value Limit
9696
~~~~~~~~~~~~~~~~~
9797

98-
For :doc:`indexed collections </indexes>`, the values
99-
for the indexed fields have a
100-
:limit:`Maximum Index Key Length <Index Key Limit>` limit. See
101-
:limit:`Maximum Index Key Length <Index Key Limit>` for details.
98+
99+
MongoDB 2.6 through MongoDB versions with :ref:`featureCompatibilityVersion <view-fcv>` (fCV) set to ``"4.0"`` or earlier
100+
For :doc:`indexed collections </indexes>`, the values for the
101+
indexed fields have a :limit:`Maximum Index Key Length <Index Key Limit>`. See
102+
:limit:`Maximum Index Key Length <Index Key Limit>` for details.
102103

103104
.. _document-dot-notation:
104105

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ref: 4.2-downgrade-fcv-index-key
2+
content: |
3+
4+
Starting in MongoDB 4.2, for ``featureCompatibilityVersion`` set to
5+
``"4.2"`` or greater, MongoDB removes the :limit:`Index Key Limit`. For
6+
``featureCompatibilityVersion`` set to ``"4.0"``, the limit still
7+
applies.
8+
9+
If you have an index with keys that exceed the :limit:`Index Key
10+
Limit` once ``featureCompatibilityVersion`` is set to ``"4.0"``,
11+
consider changing the index to a hashed index or to indexing a
12+
computed value. You can also **temporarily** use
13+
:parameter:`failIndexKeyTooLong` set to ``false`` before resolving
14+
the problem. However, withs :parameter:`failIndexKeyTooLong` set to
15+
``false``, queries that use these indexes can return incomplete
16+
results.
17+
18+
...

source/includes/list-index-field-limit-behaviors.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
MongoDB versions 2.6 and greater implement a stronger enforcement of the limit on
2-
:limit:`index key <Index Key Limit>`:
1+
When the :limit:`Index Key Limit` applies:
32

43
- .. include:: /includes/fact-index-key-length-operation-behaviors.rst
54
:start-after: index-field-limit-ensureIndex

source/reference/limits.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,22 @@ Indexes
113113
.. _limit-index-size:
114114
.. limit:: Index Key Limit
115115

116-
The *total size* of an index entry, which can include structural
117-
overhead depending on the BSON type, must be *less than* 1024 bytes.
116+
.. versionchanged:: 4.2
117+
118+
MongoDB removes the :limit:`Index Key Limit` for fCV set to
119+
``"4.2"`` or greater.
120+
121+
For MongoDB 2.6 through MongoDB versions with
122+
:ref:`featureCompatibilityVersion <view-fcv>` (fCV) set to ``"4.0"``
123+
or earlier, the *total size* of an index entry, which can include
124+
structural overhead depending on the BSON type, must be *less than*
125+
1024 bytes.
118126

119127
.. COMMENT refer to src/mongo/db/structure/btree/key.cpp (KeyV1Owned::KeyV1Owned)
120128

121129
.. |limit| replace:: :limit:`index key limit <Index Key Limit>`
122130

123-
.. versionchanged:: 2.6
124-
125-
.. include:: /includes/list-index-field-limit-behaviors.rst
131+
.. include:: /includes/list-index-field-limit-behaviors.rst
126132

127133
.. _limit-number-of-indexes-per-collection:
128134
.. limit:: Number of Indexes per Collection

source/reference/parameters.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,25 @@ General Parameters
540540

541541
.. parameter:: failIndexKeyTooLong
542542

543-
.. versionadded:: 2.6
544-
545543
|mongod-only|
546544

547-
In MongoDB 2.6, if you attempt to insert or update a document so
548-
that the value of an indexed field is longer than the
549-
:limit:`Index Key Length Limit <Index Key Limit>`, the operation
550-
will fail and return an error to the client. In previous versions
551-
of MongoDB, these operations would successfully insert or modify a
552-
document but the index or indexes would not include references to
553-
the document.
545+
.. versionchanged:: 4.2
546+
547+
- MongoDB removes the :limit:`Index Key Limit` for
548+
:ref:`featureCompatibilityVersion <view-fcv>` (fCV) set to
549+
``"4.2"`` or greater.
550+
551+
- In concert with the removal of the limit,
552+
:parameter:`failIndexTooLong` only applies for MongoDB 2.6
553+
through MongoDB versions with :ref:`featureCompatibilityVersion
554+
<view-fcv>` (fCV) set to ``"4.0"`` or earlier.
555+
556+
For MongoDB 2.6 through MongoDB versions with
557+
``featureCompatibilityVersion`` (fCV) set to ``"4.0"`` or earlier,
558+
:limit:`Index Key Length Limit <Index Key Limit>` applies. If you
559+
attempt to insert or update a document whose index field exceeds
560+
the :limit:`Index Key Length Limit <Index Key Limit>`, the operation
561+
will fail and return an error to the client.
554562

555563
To avoid this issue, consider using :doc:`hashed indexes
556564
</core/index-hashed>` or indexing a computed value. If you have an
@@ -568,9 +576,7 @@ General Parameters
568576
documents whose indexed fields exceed the
569577
:limit:`Index Key Length Limit <Index Key Limit>`.
570578

571-
:parameter:`failIndexKeyTooLong` defaults to ``true``. When
572-
``false``, a 2.6 :binary:`~bin.mongod` instance will provide the 2.4
573-
behavior.
579+
:parameter:`failIndexKeyTooLong` defaults to ``true``.
574580

575581
Issue the following command to disable the index key length
576582
validation:

source/reference/program/mongorestore.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ Rebuild Indexes
5050

5151
.. note::
5252

53-
Starting in MongoDB 2.6, creating indexes will :ref:`error if an
53+
For MongoDB 2.6 through MongoDB versions with
54+
``featureCompatibilityVersion`` (fCV) set to ``"4.0"`` or earlier,
55+
creating indexes will :limit:`error if an
5456
index key in an existing document exceeds the limit
55-
<2.6-index-key-length-incompatibility>`. See
56-
:ref:`2.6-index-key-length-incompatibility` for more information and
57-
solution.
58-
59-
If you have an existing data set that violates this limit but want
60-
to resolve the index issue after restoring the data, you can disable
61-
the default index key length validation on the target database by
62-
setting the :program:`mongod` instance's
63-
:parameter:`failIndexKeyTooLong` parameter to false.
57+
<Index Key Limit>`.
58+
59+
To avoid this issue, consider using hashed indexes or indexing a
60+
computed value instead. If you want to resolve the index issue after
61+
restoring the data, you can disable the default index key length
62+
validation on the target database by setting the :program:`mongod`
63+
instance's :parameter:`failIndexKeyTooLong` parameter to false.
6464

6565
Version Compatibility
6666
~~~~~~~~~~~~~~~~~~~~~

source/release-notes/4.2-compatibility.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,15 @@ General Changes
227227

228228
.. _4.2-compatibility-enabled:
229229

230-
4.2 Feature Compatibilitity
231-
---------------------------
230+
4.2 Feature Compatibility
231+
-------------------------
232232

233233
Some features in 4.2 require not just the 4.2 binaries but the
234-
``featureCompatibilityVersion`` set to 4.2. These features include:
234+
:ref:`featureCompatibilityVersion <view-fcv>` (fCV) set to 4.2. These
235+
features include:
236+
237+
- Removal of :limit:`Index Key Limit` for MongoDB versions with fCV set
238+
to 4.2+. In concert with the removal of this limit, the
239+
:parameter:`failIndexKeyTooLong` parameter has no effect for MongoDB
240+
versions with fCV set to 4.2+ and only applies for MongoDB 2.6
241+
through MongoDB versions with fCV set to ``"4.0"`` or earlier.

source/release-notes/4.2-downgrade-replica-set.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ value, see :ref:`view-fcv`.
8080
2. Remove Backwards Incompatible Persisted Features
8181
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8282

83+
Index Key Size
84+
``````````````
85+
86+
.. include:: /includes/extracts/4.2-downgrade-fcv-index-key.rst
87+
8388

8489
Procedure
8590
---------

source/release-notes/4.2-downgrade-sharded-cluster.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ value, see :ref:`view-fcv`.
7878
2. Remove Backwards Incompatible Persisted Features
7979
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8080

81+
Index Key Size
82+
``````````````
83+
84+
.. include:: /includes/extracts/4.2-downgrade-fcv-index-key.rst
85+
8186

8287
Procedure
8388
---------

source/release-notes/4.2-downgrade-standalone.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ versions as outlined below. These steps are necessary only if
5252
2. Remove Backwards Incompatible Persisted Features
5353
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5454

55+
Index Key Size
56+
``````````````
57+
58+
.. include:: /includes/extracts/4.2-downgrade-fcv-index-key.rst
59+
5560

5661
Procedure
5762
---------

source/release-notes/4.2.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ this option, you can start a change stream from an
247247
missed notifications after the previous stream was invalidated.
248248

249249

250-
251250
General Improvements
252251
--------------------
253252

@@ -258,6 +257,16 @@ MongoDB 4.2 adds the :option:`--outputConfig <mongod --outputConfig>` option for
258257
:binary:`~bin.mongod` and :binary:`~bin.mongos`, which outputs the resolved
259258
YAML configuration document to ``stdout`` and halts the server instance.
260259

260+
Remove Index Key Size Limit
261+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
262+
263+
Starting in MongoDB 4.2, for :ref:`featureCompatibilityVersion
264+
<view-fcv>` set to ``"4.2"`` or greater, MongoDB removes the
265+
:limit:`Index Key Limit`. For fCV set to ``"4.0"``, the limit still
266+
applies.
267+
268+
.. seealso:: :ref:`4.2-compatibility-enabled`
269+
261270
Changes Affecting Compatibility
262271
-------------------------------
263272

0 commit comments

Comments
 (0)