[SERVER-26883] Division by zero crash at config server if no shards contain a tag Created: 02/Nov/16  Updated: 19/Nov/16  Resolved: 03/Nov/16

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.4.0-rc2
Fix Version/s: 3.4.0-rc3

Type: Bug Priority: Major - P3
Reporter: Timothy Olsen (Inactive) Assignee: Kaloian Manassiev
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File cfg.log     Text File mongos.log     Text File shard0.log     Text File shard1.log    
Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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
Participants:

 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.



 Comments   
Comment by Githook User [ 03/Nov/16 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-26883 Skip sharding zone if no shards are assigned to it
Branch: master
https://github.com/mongodb/mongo/commit/1c64fe009f52c712a03b8934114c7b5c92b2f139

Comment by Kaloian Manassiev [ 02/Nov/16 ]

This looks like a division by zero error when there are no shards matching a tag. Thank you for the report.

Comment by Timothy Olsen (Inactive) [ 02/Nov/16 ]

non-SSL OS X

Comment by Kaloian Manassiev [ 02/Nov/16 ]

tim.olsen - I am unable to reproduce this crash. Can you tell me exactly which variant of the RC2 build did you use so I can resolve the stack trace?

Generated at Thu Feb 08 04:13:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.