Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9931

hashed shard keys do not appear to handle decimal values

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.2
    • Component/s: Sharding
    • Labels:
      None
    • ALL
    • Hide

      // Set up a sharding test.
      var st = new ShardingTest({ shards : 4, mongos: 1, chunksize : 64, config : 1, other : { nopreallocj : 1 }});
      st.adminCommand(

      { enablesharding:"test" }

      );
      st.adminCommand( { shardcollection:"test.hashed", key:

      { _id: 'hashed' }

      } );

      function insertData(db, colName, num, w) {
          start=db.serverStatus().uptimeMillis;
          col = db.getCollection(colName);
      col.remove();
          for (i = 0; i < num; i++) {
              col.insert({_id: Math.random()});
              db.getLastErrorObj(w); // call gle safe
          }
          end=db.serverStatus().uptimeMillis;
          return ((num*1000)/(end-start));
      }

      //
      num = 50000;
      hashed=insertData(db.getSiblingDB( "test" ), 'hashed', num,1);

      Show
      // Set up a sharding test. var st = new ShardingTest({ shards : 4, mongos: 1, chunksize : 64, config : 1, other : { nopreallocj : 1 }}); st.adminCommand( { enablesharding:"test" } ); st.adminCommand( { shardcollection:"test.hashed", key: { _id: 'hashed' } } ); function insertData(db, colName, num, w) {     start=db.serverStatus().uptimeMillis;     col = db.getCollection(colName); col.remove();     for (i = 0; i < num; i++) {         col.insert({_id: Math.random()});         db.getLastErrorObj(w); // call gle safe     }     end=db.serverStatus().uptimeMillis;     return ((num*1000)/(end-start)); } // num = 50000; hashed=insertData(db.getSiblingDB( "test" ), 'hashed', num,1);

      Tried using a hashed shard key after defining an empty collection as hashed sharded. All decimal values between 0 and 1 were routed to the same shard.

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            edouard Edouard Servan-Schreiber
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: