[SERVER-44619] BtreeKeyGenerator::_extractNextElement() uassert message exceeds 16mb BSON document limit when added to a command result Created: 14/Nov/19  Updated: 29/Oct/23  Resolved: 15/Nov/19

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.3.1, 4.2.3

Type: Bug Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Sprint: Execution Team 2019-11-18
Participants:
Linked BF Score: 11

 Description   

When we attempt to index a document that is ambiguous for the key pattern {‘a.0’: 1}, BtreeKeyGenerator::_extractNextElement() includes the contents of the array field in the uassert error message, with error code 16746. When the command processing subsystem converts this UserAssertion into a Status for the createIndexes command result, the result may exceed the 16 MB BSON document limit, leading to a different error code BSONObjectTooLarge returned in the final result. This obscures the original source of the indexing error.

To reproduce:

// Add a small document first. We cannot transmit a document larger than the 16mb over the wire.
const dupDoc = {a: [{'0': 1}]};
t.save(dupDoc);
 
// This extends the array with nulls before append the requested integer.
// The 1,5000,000 constant is based on a limit defined in path_support.h
t.update({}, {$set: {'a.1500001': 1}});
 
// This should fail with an error code of 16746 instead of BSONObjectTooLarge.
t.ensureIndex({'a.0': 1});



 Comments   
Comment by Githook User [ 11/Dec/19 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-44619 add expected error code to test

(cherry picked from commit e6deb004dfb74bbf0c381597185ea7cf88a9a812)
Branch: v4.2
https://github.com/mongodb/mongo/commit/25a8a0b4eb4f9466f1e60395ad22379416b20a76

Comment by Githook User [ 11/Dec/19 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-44619 truncate message for error code 16746 if too long

(cherry picked from commit 3f4312f26e1667826db51a0d2834eb417bb5de2d)
Branch: v4.2
https://github.com/mongodb/mongo/commit/944e3cd772e65b2bc04e7792f8a6420efa83d528

Comment by Githook User [ 14/Nov/19 ]

Author:

{'name': 'Benety Goh', 'username': 'benety', 'email': 'benety@mongodb.com'}

Message: SERVER-44619 add expected error code to test
Branch: master
https://github.com/mongodb/mongo/commit/e6deb004dfb74bbf0c381597185ea7cf88a9a812

Comment by Githook User [ 14/Nov/19 ]

Author:

{'name': 'Benety Goh', 'username': 'benety', 'email': 'benety@mongodb.com'}

Message: SERVER-44619 truncate message for error code 16746 if too long
Branch: master
https://github.com/mongodb/mongo/commit/3f4312f26e1667826db51a0d2834eb417bb5de2d

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