[SERVER-14287] ensureIndex can abort reIndex and lose indexes Created: 17/Jun/14  Updated: 19/Jun/15  Resolved: 15/Oct/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.6.5
Fix Version/s: 2.6.6

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

Issue Links:
Depends
Tested
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Executing ensureIndex on an existing index while a reIndex operation is in process may terminate the reIndex operation early with an error 68 (index already exists), and the remaining indexes will have been dropped and never get rebuilt. Reproduce as follows:

setup.js

    db.c.drop()
    db.c.ensureIndex({a:1}, {background:true})
    db.c.ensureIndex({b:1}, {background:true})
    db.c.ensureIndex({c:1}, {background:true})
    db.c.ensureIndex({d:1}, {background:true})
    db.c.ensureIndex({e:1}, {background:true})
    for (var i=0; i<500; i++)
        db.c.insert({})

ensure.js:

    while (true) {
        db.c.ensureIndex({c:1})
    }

reindex.js:

    while (true) {
        result = db.c.reIndex()
        if ('nIndexes' in result) {
            print('nIndexes', result.nIndexes)
        }
        if ('errmsg' in result) {
            printjson(result)
        }
        sleep(100)
    }

repro:

mongo test setup.js
(sleep 1; mongo test ensure.js) &
mongo test reindex.js

After 1 second when the ensureIndexes start the reIndexes will error out with code 68 and the number of indexes will drop to 3.



 Comments   
Comment by Githook User [ 15/Oct/14 ]

Author:

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

Message: SERVER-14287 do not run bg index builds that aren't interruptable
Branch: v2.6
https://github.com/mongodb/mongo/commit/392617ce3977b95b582238d7b7a77631ff22d206

Generated at Thu Feb 08 03:34:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.