[SERVER-17449] collection.ensureIndex should ignore unsupported options Created: 03/Mar/15  Updated: 03/Mar/15  Resolved: 03/Mar/15

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

Type: Improvement Priority: Major - P3
Reporter: Stefan Wójcik Assignee: Unassigned
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-769 Validate top-level & index spec field... Closed
Participants:

 Description   

Running MongoDB 2.6.8, I get:

> db.notification.getIndexes()[1]
{
	"v" : 1,
	"key" : {
		"_cls" : 1,
		"membership" : 1
	},
	"ns" : "closeio.notification",
	"name" : "_cls_1_membership_1",
	"background" : false,
	"dropDups" : false
}
> db.notification.ensureIndex({ _cls: 1, membership: 1 })
{ "numIndexesBefore" : 14, "note" : "all indexes already exist", "ok" : 1 }
> db.notification.ensureIndex({ _cls: 1, membership: 1 }, { background: true })
{ "numIndexesBefore" : 14, "note" : "all indexes already exist", "ok" : 1 }
> db.notification.ensureIndex({ _cls: 1, membership: 1 }, { whatever: true })
{
	"ok" : 0,
	"errmsg" : "Index with name: _cls_1_membership_1 already exists with different options",
	"code" : 85
}
> db.notification.ensureIndex({ _cls: 1, membership: 1, whatever:1 }, { whatever: true })
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 14,
	"numIndexesAfter" : 15,
	"ok" : 1
}
> db.notification.getIndexes()[14]
{
	"v" : 1,
	"key" : {
		"_cls" : 1,
		"membership" : 1,
		"whatever" : 1
	},
	"name" : "_cls_1_membership_1_whatever_1",
	"ns" : "closeio.notification",
	"whatever" : true
}

1. Calling ensureIndex with an unsupported option shouldn't consider the spec different from the existing one (i.e. the error shouldn't occur).
2. Options that aren't supported shouldn't be stored on the index spec.

Do you agree?



 Comments   
Comment by Ramon Fernandez Marina [ 03/Mar/15 ]

Thanks for your report wojcikstefan. This ticket is a duplicate of SERVER-769 – please feel free to watch / vote for SERVER-769.

Regards,
Ramón.

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