hashed shard keys do not appear to handle decimal values

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.4.2
    • Component/s: Sharding
    • 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);
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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 Studer (Inactive)
            Reporter:
            Edouard Servan-Schreiber (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: