[SERVER-29191] Dropping an index named "*" is ambiguous because createIndexes permits an index to be named "*" Created: 14/May/17  Updated: 30/Oct/23  Resolved: 07/Jul/17

Status: Closed
Project: Core Server
Component/s: Querying, Replication
Affects Version/s: 3.5.5
Fix Version/s: 3.5.10

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Matthew Russotto
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-10523 Docs for SERVER-29191: Dropping an in... Closed
Related
is related to SERVER-28200 Recoverable Rollback: Extend dropInde... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

python buildscripts/resmoke.py --executor=jstestfuzz_replication repro_server29191.js

repro_server29191.js

var rst = new ReplSetTest({nodes: 2});
rst.startSet();
rst.initiate();
 
var primaryDB = rst.getPrimary().getDB("test");
var secondaryDB = rst.getSecondary().getDB("test");
 
assert.commandWorked(primaryDB.mycoll.createIndex({x: 1}));
assert.commandWorked(primaryDB.mycoll.createIndex({y: 1}, "*"));
assert.commandWorked(primaryDB.mycoll.dropIndex({y: 1}));
 
rst.awaitReplication();
 
var indexes = primaryDB.mycoll.getIndexes();
assert.eq(2, indexes.length, tojson(indexes));
 
indexes = secondaryDB.mycoll.getIndexes();
assert.eq(2, indexes.length, tojson(indexes));
 
rst.stopSet();

Sprint: Repl 2017-07-10
Participants:
Linked BF Score: 0

 Description   

Prior to the changes from 6fd95f8 as part of SERVER-28200, the oplog entry for the "dropIndexes" command represented the index using its key pattern rather than its name. Dropping an index named "*" is interpreted by the replication subsystem as dropping all indexes and can cause the primary and secondaries not to have the same set of indexes.

CC judah.schvimer



 Comments   
Comment by Githook User [ 06/Jul/17 ]

Author:

{u'username': u'mtrussotto', u'name': u'Matthew Russotto', u'email': u'matthew.russotto@10gen.com'}

Message: SERVER-29191 Dropping an index named "" is ambiguous because createIndexes permits an index to be named ""

Disallows creating or individually dropping an index named "*".
Branch: master
https://github.com/mongodb/mongo/commit/1447d3db59804752e6c2882a6a8a4a14d7ae71ad

Comment by Judah Schvimer [ 12/Jun/17 ]

Okay, so we will prevent new indexes from being named "*". The only way to drop a "*" index is by key pattern, since dropping by the name "*" will drop all indexes, so before we drop an index by key pattern here we will check if it's name is "*" and if so return an error saying they must drop the collection or downgrade to drop the index.

Comment by Eric Milkie [ 09/Jun/17 ]

I think we should make 3.6 prevent new indexes from being named "*", but grandfather in preexisting ones. We should also prevent indexes named "*" from being individually dropped. The only ways to drop them will be to either drop the underlying collection or downgrade.

Comment by Max Hirschhorn [ 09/Jun/17 ]

One option would be to just disallow creating collections named "*". If any users had already created an index named "*", dropping it would drop all of their indexes on secondaries, and no future version of mongodb would prevent that.

judah.schvimer, I doubt a user actually created an index named "*", so I don't think it would too significant of a breaking change to reject them in MongoDB 3.6. This would involve making MongoDB 3.6 fail to start if there's an existing index named "*" or a MongoDB 3.6 secondary receives an oplog entry to create an index named "*". milkie, do you have thoughts about what we should do here?

Comment by Judah Schvimer [ 23/May/17 ]

max.hirschhorn, Do you have a proposed fix? One option would be to just disallow creating collections named "*". If any users had already created an index named "*", dropping it would drop all of their indexes on secondaries, and no future version of mongodb would prevent that. Alternatively, we no longer make oplog entries that drop multiple indexes, so we could make it so secondaries do not drop all their indexes when they receive a "*" and rather just drop the "*" named index. This would special case oplog application which is not normal, and if a new server replayed an old oplog entry that meant for it to drop all of its indexes, it would only drop an index named "*".

Comment by Ian Whalen (Inactive) [ 19/May/17 ]

judah.schvimer since this was related to your work we're passing this to the repl backlog but query is happy to do the CR.

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