[SERVER-29197] Dangling index records when initial syncing node clones a capped collection that deletes records during collection scan Created: 15/May/17  Updated: 30/Oct/23  Resolved: 31/May/17

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.4.4
Fix Version/s: 3.4.6, 3.5.9

Type: Bug Priority: Critical - P2
Reporter: Eric Milkie Assignee: Eric Milkie
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-29240 Add test to ensure valid index creati... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Sprint: Storage 2017-05-29, Storage 2017-06-19
Participants:

 Description   

During an initial sync of a capped collection, the collection scan reads until it hits EOF. If records are inserted on the sync source during the collection scan, the scan may read more documents than the collection cap allows, which will result in records being deleted during the collection scan.
The collection cloner for initial sync uses a MultiIndexBlock builder, which does not expect records to be deleted while it builds indexes. If records are deleted before the MultiIndexBlock commits at the end of the collection scan, it can leave dangling index records pointing to deleted records. On WiredTiger, this simply results in an error when the index records are scanned. On MMAPv1, the index records point to invalid record data, which may or may not produce a BSON parsing error that looks like this:

2017-05-15T09:45:48.697-0400 I -        [conn3] Assertion: 10334:BSONObj size: -286331154 (0xEEEEEEEE) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: ObjectId('5919b0b5f337b48af7a0be4d') src/mongo/bson/bsonobj.cpp 58

The collections in question will fail an index validation by the validate command. To repair this issue, run the reindex command.



 Comments   
Comment by Githook User [ 14/Jun/17 ]

Author:

{u'username': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-29197 initial sync now builds capped indexes correctly

In initial sync, capped indexes were built along with regular indexes, as documents were inserted, using the MultiIndexBlock.
This structure requires that no records are deleted before committing the index builds. But the collection cap might delete records prior to commit.
The new way to build capped indexes will be to create the indexes on a capped collection prior to inserting any records, for initial sync.

(cherry picked from commit 3a3a6def395bab81e7545b15a93bee7799d9efb1)
Branch: v3.4
https://github.com/mongodb/mongo/commit/34d292df70c97fadbac07296dea3cb04b6021a4d

Comment by Githook User [ 31/May/17 ]

Author:

{u'username': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-29197 initial sync now builds capped indexes correctly

In initial sync, capped indexes were built along with regular indexes, as documents were inserted, using the MultiIndexBlock.
This structure requires that no records are deleted before committing the index builds. But the collection cap might delete records prior to commit.
The new way to build capped indexes will be to create the indexes on a capped collection prior to inserting any records, for initial sync.
Branch: master
https://github.com/mongodb/mongo/commit/3a3a6def395bab81e7545b15a93bee7799d9efb1

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