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

Division by zero crash at config server if no shards contain a tag

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc3
    • Affects Version/s: 3.4.0-rc2
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • Hide

      Set up a sharded cluster.

      Then follow the following shell session:

      mongos> sh.addShard("rs0/liquid.local:27000")
      { "shardAdded" : "rs0", "ok" : 1 }
      mongos>  sh.addShard("rs1/liquid.local:27001")
      { "shardAdded" : "rs1", "ok" : 1 }
      mongos> sh.enableSharding("testDb")
      { "ok" : 1 }
      mongos> use testDb
      switched to db testDb
      mongos> for (i = 0; i < 1000; i++) { db.testColl.insert({b: i, c: "a" + i}) }
      WriteResult({ "nInserted" : 1 })
      mongos> db.testColl.createIndex({b: 1, c: 1})
      {
      	"raw" : {
      		"rs0/liquid.local:27000" : {
      			"createdCollectionAutomatically" : false,
      			"numIndexesBefore" : 1,
      			"numIndexesAfter" : 2,
      			"ok" : 1,
      			"$gleStats" : {
      				"lastOpTime" : {
      					"ts" : Timestamp(1478110308, 1),
      					"t" : NumberLong(1)
      				},
      				"electionId" : ObjectId("7fffffff0000000000000001")
      			}
      		}
      	},
      	"ok" : 1
      }
      mongos> sh.shardCollection("testDb.testColl", {b: 1, c: 1})
      { "collectionsharded" : "testDb.testColl", "ok" : 1 }
      mongos> use config
      switched to db config
      mongos> db.tags.insert({ "_id" : { "ns" : "testDb.testColl", "min" : { "b" : 0, "c" : "a0" } }, "ns" : "testDb.testColl", "min" : { "b" : 0, "c" : "a0" }, "max" : { "b" : 1000, "c" : "a1000" }, "tag" : "tag" })
      WriteResult({ "nInserted" : 1 })
      mongos> db.tags.remove({})
      
      Show
      Set up a sharded cluster. Then follow the following shell session: mongos> sh.addShard("rs0/liquid.local:27000") { "shardAdded" : "rs0", "ok" : 1 } mongos> sh.addShard("rs1/liquid.local:27001") { "shardAdded" : "rs1", "ok" : 1 } mongos> sh.enableSharding("testDb") { "ok" : 1 } mongos> use testDb switched to db testDb mongos> for (i = 0; i < 1000; i++) { db.testColl.insert({b: i, c: "a" + i}) } WriteResult({ "nInserted" : 1 }) mongos> db.testColl.createIndex({b: 1, c: 1}) { "raw" : { "rs0/liquid.local:27000" : { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1, "$gleStats" : { "lastOpTime" : { "ts" : Timestamp(1478110308, 1), "t" : NumberLong(1) }, "electionId" : ObjectId("7fffffff0000000000000001") } } }, "ok" : 1 } mongos> sh.shardCollection("testDb.testColl", {b: 1, c: 1}) { "collectionsharded" : "testDb.testColl", "ok" : 1 } mongos> use config switched to db config mongos> db.tags.insert({ "_id" : { "ns" : "testDb.testColl", "min" : { "b" : 0, "c" : "a0" } }, "ns" : "testDb.testColl", "min" : { "b" : 0, "c" : "a0" }, "max" : { "b" : 1000, "c" : "a1000" }, "tag" : "tag" }) WriteResult({ "nInserted" : 1 }) mongos> db.tags.remove({})
    • Sharding 2016-11-21

      It is possible to get into this situation if you first add the shard tag range manually to the config.tags collection. (The sh.addTagRange() helper will refuse to add the tag range if the tag does not currently map to any shards).

      Of course this is an instance of "don't do that. use the helper." I'd thought I'd file this anyway if you wanted to work on preventing the crash from occurring.

      Logs attached.

        1. cfg.log
          31 kB
          Timothy Olsen
        2. mongos.log
          441 kB
          Timothy Olsen
        3. shard0.log
          138 kB
          Timothy Olsen
        4. shard1.log
          188 kB
          Timothy Olsen

            Assignee:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Reporter:
            tim.olsen@mongodb.com Timothy Olsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: