[SERVER-32048] Updates using a numeric path component may cause index entries not to be created Created: 21/Nov/17  Updated: 30/Oct/23  Resolved: 06/Dec/17

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 3.0.15, 3.2.17, 3.4.10, 3.6.0-rc4
Fix Version/s: 3.0.16, 3.2.19, 3.4.11, 3.6.1, 3.7.1

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6, v3.4, v3.2, v3.0
Sprint: Query 2017-12-04, Query 2017-12-18
Participants:
Linked BF Score: 0

 Description   
Issue Status as of Dec 15, 2017

ISSUE SUMMARY
Updates over array elements with an explicit numerical path component (e.g. a.5.c), where the array element does not yet exist, can fail to generate null index keys for multikey indexes on other fields in the array element (e.g. for the index {"a.b": 1}). Updates using the $ positional operator are not affected. This index corruption will cause equality to null queries to miss results.

UPDATES CAUSING INDEX CORRUPTION
The following updates will fail to generate a null index key for the index {"a.b": 1}:

  • Updates to a.<n>.c, where <n> is an integer greater than or equal to the length of the array a, and a is not empty. The update must create the array element a.<n> to cause index corruption, so it must be one of $set, $inc, $mul, $addToSet, $bit, $min, $max, $currentDate, or $push, $pushAll.

The following updates are not affected:

  • Updates to a.<n>.c, where <n> is less than the length of the array a.
  • Updates to a.<n>.c, when the array a is empty.
  • Updates to a.$.c.
  • Updates to a.<n>.
  • $rename, $setOnInsert, $unset, $pop, $pull, and $pullAll.

QUERIES AFFECTED BY INDEX CORRUPTION
The following queries will miss results due to index corruption of {"a.b": 1}:

  • {"a.b": null}

The following queries are not affected:

  • {"a.b": {$exists: false}}
  • {"a.b": {$exists: true}}
  • {"a.b": {$ne: null}}

HOW DO I TELL WHETHER I'M AFFECTED?
If you have never issued updates with explicit numerical path components, you're not affected. In order to test whether you are affected, run the validate command with full:true.

HOW DO I RECOVER?
Rebuild any affected indexes.

HOW TO PREVENT THIS ISSUE?
Upgrade to a version where this issue is fixed. The issue is fixed in 3.6.1, 3.4.11, 3.2.19, 3.0.16.

AFFECTED VERSIONS
This affects 3.0.15 and earlier versions of 3.0; 3.2.18 and earlier versions of 3.2; 3.4.10 and earlier versions of 3.4; 3.6.0 and earlier versions of 3.6.

FIX VERSION
3.6.1, 3.4.11, 3.2.19, 3.0.16



 Comments   
Comment by Githook User [ 15/Dec/17 ]

Author:

{'name': 'Tess Avitabile', 'username': 'tessavitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-32048 Ensure updates that implicitly create an array element generate new null index keys

(cherry picked from commit 69f94d7172801725bad43dba99ca0e5400eb293c)
(cherry picked from commit 80b311e0a8537a47eb723ed4b6c010b5d1006551)
(cherry picked from commit 5e58d9f0b6e6b42a0c9f4817e88ee1bfb7527d81)
(cherry picked from commit 752daa306095fb1610bb5db13b7b106ac87ec6cb)
Branch: v3.0
https://github.com/mongodb/mongo/commit/59af713ebb0004c73a2891759ac28ed580e8b4b1

Comment by Githook User [ 14/Dec/17 ]

Author:

{'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com', 'username': 'tessavitabile'}

Message: SERVER-32048 Ensure updates that implicitly create an array element generate new null index keys

(cherry picked from commit 69f94d7172801725bad43dba99ca0e5400eb293c)
(cherry picked from commit 80b311e0a8537a47eb723ed4b6c010b5d1006551)
(cherry picked from commit 5e58d9f0b6e6b42a0c9f4817e88ee1bfb7527d81)
Branch: v3.2
https://github.com/mongodb/mongo/commit/752daa306095fb1610bb5db13b7b106ac87ec6cb

Comment by Githook User [ 12/Dec/17 ]

Author:

{'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com', 'username': 'tessavitabile'}

Message: SERVER-32048 Ensure updates that implicitly create an array element generate new null index keys

(cherry picked from commit 69f94d7172801725bad43dba99ca0e5400eb293c)
(cherry picked from commit 80b311e0a8537a47eb723ed4b6c010b5d1006551)
Branch: v3.4
https://github.com/mongodb/mongo/commit/5e58d9f0b6e6b42a0c9f4817e88ee1bfb7527d81

Comment by Githook User [ 11/Dec/17 ]

Author:

{'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com', 'username': 'tessavitabile'}

Message: SERVER-32048 Ensure updates that implicitly create an array element generate new null index keys

(cherry picked from commit 69f94d7172801725bad43dba99ca0e5400eb293c)
Branch: v3.6
https://github.com/mongodb/mongo/commit/80b311e0a8537a47eb723ed4b6c010b5d1006551

Comment by Githook User [ 06/Dec/17 ]

Author:

{'name': 'Tess Avitabile', 'username': 'tessavitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-32048 Ensure updates that implicitly create an array element generate new null index keys
Branch: master
https://github.com/mongodb/mongo/commit/69f94d7172801725bad43dba99ca0e5400eb293c

Generated at Thu Feb 08 04:29:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.