[SERVER-12955] Repair resets database data file version to 4.5 Created: 28/Feb/14  Updated: 11/Jul/16  Resolved: 28/Feb/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Storage
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.6.0-rc1

Type: Bug Priority: Major - P3
Reporter: Kamran K. Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

Running repairDatabase on a data file version 4.6 database incorrectly sets the data file version on the new database to 4.5 instead of 4.6. This corrupts any existing text/2dsphere indexes, which are built correctly during the repair but then treated as ascending on subsequent document modifications.

Regression since 2.5.5.

> db.dropDatabase()
{ "dropped" : "test", "ok" : 1 }
> db.foo.ensureIndex({a:"text"})
WriteResult({ "nInserted" : 1 })
> db.foo.insert({a:"hello world"})
WriteResult({ "nInserted" : 1 })
> db.foo.validate().keysPerIndex
{ "test.foo.$_id_" : 1, "test.foo.$a_text" : 2 }
> db.stats().dataFileVersion
{ "major" : 4, "minor" : 6 }
> db.repairDatabase()
{ "ok" : 1 }
> db.stats().dataFileVersion
{ "major" : 4, "minor" : 5 } // incorrect: wrong version
> db.foo.validate().keysPerIndex
{ "test.foo.$_id_" : 1, "test.foo.$a_text" : 2 } // correct: two text index entries
> db.foo.insert({a:"hello world"})
WriteResult({ "nInserted" : 1 })
> db.foo.validate().keysPerIndex
{ "test.foo.$_id_" : 2, "test.foo.$a_text" : 3 } // incorrect: treated as ascending index (only one key added)
>

Original description (title "repairDatabase prevents new text and 2dsphere indexes from being created"):

After running repairDatabase, 2dsphere and text indexes can no longer be created on new collections.

var myDB = db.getSiblingDB('repaired');
assert.commandWorked(myDB.dropDatabase());
 
myDB.one.ensureIndex({h: "2dsphere"});
myDB.runCommand({repairDatabase: 1});
myDB.two.ensureIndex({h: "2dsphere"});

Error after the last step:

WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 67,
		"errmsg" : "Found pre-existing index { v: 1, key: { h: \"2dsphere\" }, name: \"h_2dsphere\", ns: \"repaired.one\", 2dsphereIndexVersion: 2 } with invalid type '2dsphere'. Disallowing creation of new index type '2dsphere'. See http://dochub.mongodb.org/core/index-type-changes"
	}
})


Version: b605f98c68a03fd0e65be72f9a22af4f107dee6b



 Comments   
Comment by Githook User [ 28/Feb/14 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-12955: MultiIndexBlock needs to check pdfile version
Branch: master
https://github.com/mongodb/mongo/commit/914a26f51ff7ffeb28922273925318da6a6eba71

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