[SERVER-10539] Missed index for sharding key Created: 16/Aug/13  Updated: 06/Dec/22  Resolved: 06/Sep/18

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

Type: Bug Priority: Major - P3
Reporter: Nazar Volynets Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Done Votes: 0
Labels: sharding
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS: Ubuntu 12.04
Mongo: Sharded cluster based on MongoDB 2.2.1 for Linux


Assigned Teams:
Sharding
Operating System: ALL
Steps To Reproduce:

MongoDB sharded cluster.

Please use Mongo shell to reproduce this issue:

mongos> use sharding_test;
mongos> sh.enableSharding("sharding_test");
 
mongos> db.createCollection('test1');
mongos> sh.shardCollection("sharding_test.test1", { 'a1234567890': 1, 'b1234567890': 1, 'c1234567890': 1 });
{ "collectionsharded" : "sharding_test.test1", "ok" : 1 }
mongos> db.test1.insert({ 'a1234567890': 1, 'b1234567890': 1, 'c1234567890': 1 });
mongos> db.test1.getIndexes();
[
        {
                "v" : 1,
                "key" : {
                        "_id" : 1
                },
                "ns" : "sharding_test.test1",
                "name" : "_id_"
        },
        {
                "v" : 1,
                "key" : {
                        "a1234567890" : 1,
                        "b1234567890" : 1,
                        "c1234567890" : 1
                },
                "ns" : "sharding_test.test1",
                "name" : "a1234567890_1_b1234567890_1_c1234567890_1"
        }
]
 
mongos> db.createCollection('test2');
mongos> sh.shardCollection("sharding_test.test2", { 'a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1, 'b1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1, 'c1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1 });
{ "collectionsharded" : "sharding_test.test2", "ok" : 1 }
mongos> db.test2.insert({ "a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1, "b1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1, "c1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1  });
mongos> db.test2.getIndexes();
[
        {
                "v" : 1,
                "key" : {
                        "_id" : 1
                },
                "ns" : "sharding_test.test2",
                "name" : "_id_"
        }
]

As you can see there is index for sharding key of sharding_test.test1 collection and no index for sharding key of sharding_test.test2.

Moreover there is no any exception observed.

Expected result (any one is acceptible):

  • at least throw exception
  • create index for sharding key if there are no suitable indexes which overlap sharding key
  • introduce possibility manually specify index name for sharding key
Participants:

 Description   

Mongo doesn't create an index for sharding key if index name (constructed by mongo in background) exceeds 128 characters.

As result such case of sharded collection without index for sharding key will cause performance degradation.

Additionally reproduced this issue by using Mongo Java Driver 2.9.3 with write concern 2 (REPLICAS_SAFE) - the same situation, no any exception observed.



 Comments   
Comment by Kaloian Manassiev [ 06/Sep/18 ]

This is a very old report and given that we have continuous integration tests which exercise this logic, we believe it is no longer a problem.

Comment by Asya Kamsky [ 25/Sep/13 ]

Possibly related issue - SERVER-7282

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