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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.0-rc2
    • Fix Version/s: 3.4.0-rc3
    • Component/s: Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      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({})
    • Sprint:
      Sharding 2016-11-21

      Description

      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.

        Attachments

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

          Activity

            People

            Assignee:
            kaloian.manassiev Kaloian Manassiev
            Reporter:
            tim.olsen Timothy Olsen
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: