[SERVER-60124] createIndex on cluster key throws IndexAlreadyExists Created: 21/Sep/21  Updated: 25/Oct/21  Resolved: 25/Oct/21

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

Type: Task Priority: Major - P3
Reporter: Haley Connelly Assignee: Haley Connelly
Resolution: Won't Do Votes: 0
Labels: PM-2311-M1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-60546 createIndex on a cluster key returns ... Closed
Sprint: Execution Team 2021-11-01
Participants:

 Description   

Creating an index on cluster key throws IndexAlreadyExists for clustered collections



 Comments   
Comment by Haley Connelly [ 22/Oct/21 ]

EDIT: we decided not to do this ticket. Instead, the createIndex command on a cluster key should fail with ErrorCodes::CannotCreateIndex as demonstrated in the current behavior

Comment by Haley Connelly [ 21/Oct/21 ]

louis.williams Throwing IndexAlreadyExists, according to scope, will let users blindly be able to run createIndex on the cluster key believe a normal index is created

If the code throws IndexAlreadyExists, it gets swallowed here.

Behavior of ignoring the error can be demonstrated on a non-clustered collection
 

assert.commandWorked(coll.createIndex({a: 1}));
assert.commandWorked(coll.createIndex({a: 1}));
assert.commandWorked(coll.createIndex({a: 1}));

I'm wondering, from a user's perspective, if we want to change it from CannotCreateIndex (the current exception thrown) to something other than IndexAlreadyExists. Another alternative that I'm not a big fan of - we could not swallow the exception in the special case of trying to create an index on the cluster key.

Generated at Thu Feb 08 05:49:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.