[SERVER-60451] Index builds code can access an invalid BSONObj because the cursor was saved&restored at a lower level Created: 04/Oct/21  Updated: 29/Oct/23  Resolved: 05/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0, 5.0.4, 5.1.0-rc0

Type: Bug Priority: Blocker - P1
Reporter: Dianna Hohensee (Inactive) Assignee: Dianna Hohensee (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
is caused by SERVER-57737 The index builds code path can throw ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.1, v5.0
Sprint: Execution Team 2021-10-18
Participants:
Linked BF Score: 118

 Description   

This objToIndex BSONObj is pointing to a cursor, which can be saved/restored and no longer save the data to which objToIndex points. Save/restore was exercised further down the stack, because we were running a createIndex command on two indexes at once, so this loop further down the stack with a reference to objToIndex can hit a WCE, save/restore the cursor, and then keep trying to use the now invalid objToIndex/doc BSONObj for the second index.

Recommendations: call getOwned() to assign a copy in objToIndex; or, update the objToIndex reference in the same lambda that restores the cursor.



 Comments   
Comment by Githook User [ 07/Oct/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-60451 Copy BSON before saving and restoring a cursor around index build side table writes

(cherry picked from commit 0300f19cd738e58cdeaa88b7406a2f38718b0ad9)
Branch: v5.0
https://github.com/mongodb/mongo/commit/a3836f36f60ed692824bf444eaecc1704fdd57fb

Comment by Githook User [ 05/Oct/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-60451 Copy BSON before saving and restoring a cursor around index build side table writes

(cherry picked from commit 0300f19cd738e58cdeaa88b7406a2f38718b0ad9)
Branch: v5.1
https://github.com/mongodb/mongo/commit/ec4438e4bd2f69fc4fa73b9123b0c7e06c28ab6f

Comment by Githook User [ 05/Oct/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-60451 Copy BSON before saving and restoring a cursor around index build side table writes
Branch: master
https://github.com/mongodb/mongo/commit/0300f19cd738e58cdeaa88b7406a2f38718b0ad9

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