[SERVER-12185] Upsert allows insertion of doc with illegally indexed parallel arrays Created: 21/Dec/13  Updated: 11/Jul/16  Resolved: 24/Dec/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.5.4
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Daniel Pasette (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

var t = db.upsert_bad_index;
t.drop();
t.ensureIndex({a: 1, b: 1});
var res = t.save({_id: 1, a: [1, 2, 3], b: [4, 5, 6]});
printjson(res);
printjson(t.validate().keysPerIndex)
assert.eq(0, t.find().itcount());



 Comments   
Comment by Githook User [ 24/Dec/13 ]

Author:

{u'username': u'monkey101', u'name': u'Dan Pasette', u'email': u'dan@10gen.com'}

Message: SERVER-12185: ensure doc is not inserted if it fails the 'cannot index parallel arrays' test
Branch: master
https://github.com/mongodb/mongo/commit/ee0365ac659fa89758263d19327d69c547eb2d50

Comment by Scott Hernandez (Inactive) [ 22/Dec/13 ]

The left-over doc is due to a failure to rollback in the index catalog.

Log level 1:

2013-12-22T09:47:06.068-0500 [conn1] User Assertion: 10088:cannot index parallel arrays [b] [a]
2013-12-22T09:47:06.068-0500 [conn1] IndexCatalog::indexRecord rollback failed: 10088 cannot index parallel arrays [b] [a]

Both the index and rollback code try to generate a set of keys for the doc which results in the exception which blocks both. Not sure how this used to work, but it did in 2.4.8, so the catalog refactoring is most likely the introduction point of this bug.

I'm happy to look into this more but it will require a bit of work. Just looking at the code paths it seems like this can be solved in the following ways:

  • don't throw assertion and use status all the way up to rollback point with cleaner logic, which will not require unindexing rollback since no indexes were touched
  • return any index keys recorded/generated from _indexRecord so _unindexRecord knows exactly what to clean up – a more general cleanup process
Generated at Thu Feb 08 03:27:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.