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

Use Regular Expression for Tag Ranges

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

      use Contador_Noticias_UN;
      sh.enableSharding("Contador_Noticias_UN");
      db.Contador.ensureIndex(

      { NodeID: 1 }

      )
      sh.shardCollection("Contador_Noticias_UN.Contador",

      {NodeID: 1}

      );

      sh.addShardTag("Shard1", "SHARD1");
      sh.addShardTag("Shard2", "SHARD2");
      sh.addShardTag("Shard3", "SHARD3");

      sh.addTagRange( "Contador_Noticias_UN.Contador",

      { NodeID: /[0-9]*0$/ }

      ,

      { NodeID: /[0-9]*3$/ }

      ,
      "SHARD1"
      )

      sh.addTagRange( "Contador_Noticias_UN.Contador",

      { NodeID: /[0-9]*4$/ }

      ,

      { NodeID: /[0-9]*6$/ }

      ,
      "SHARD2"
      )

      sh.addTagRange( "Contador_Noticias_UN.Contador",

      { NodeID: /[0-9]*7$/ }

      ,

      { NodeID: /[0-9]*9$/ }

      ,
      "SHARD3"
      )

      Show
      use Contador_Noticias_UN; sh.enableSharding("Contador_Noticias_UN"); db.Contador.ensureIndex( { NodeID: 1 } ) sh.shardCollection("Contador_Noticias_UN.Contador", {NodeID: 1} ); sh.addShardTag("Shard1", "SHARD1"); sh.addShardTag("Shard2", "SHARD2"); sh.addShardTag("Shard3", "SHARD3"); sh.addTagRange( "Contador_Noticias_UN.Contador", { NodeID: /[0-9]*0$/ } , { NodeID: /[0-9]*3$/ } , "SHARD1" ) sh.addTagRange( "Contador_Noticias_UN.Contador", { NodeID: /[0-9]*4$/ } , { NodeID: /[0-9]*6$/ } , "SHARD2" ) sh.addTagRange( "Contador_Noticias_UN.Contador", { NodeID: /[0-9]*7$/ } , { NodeID: /[0-9]*9$/ } , "SHARD3" )

      The following ranges are not working when I try to shard a collection using the NodeID field (It does not work using NodeID as a string or number)

      sh.addTagRange( "Contador_Noticias_UN.Contador",
                      { NodeID: /[0-9]*0$/ },
                      { NodeID: /[0-9]*3$/ },
                      "SHARD1"
                    )
      
      sh.addTagRange( "Contador_Noticias_UN.Contador",
                      { NodeID: /[0-9]*4$/ },
                      { NodeID: /[0-9]*6$/ },
                      "SHARD2"
                    )
      
      
      
      sh.addTagRange( "Contador_Noticias_UN.Contador",
                      { NodeID: /[0-9]*7$/ },
                      { NodeID: /[0-9]*9$/ },
                      "SHARD3"
                    )
      

      This tag ranges, must divide my workload depending of the last number of the NodeID value to 3 servers identified by the tags SHARD1, SHARD2 and SHARD3.

            Assignee:
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Reporter:
            jjperez@cadena-capriles.com Jairo Perez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: