[SERVER-20548] Suspicious chunk version initialization in ChunkManager Created: 21/Sep/15  Updated: 27/Oct/15  Resolved: 20/Oct/15

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.1.8
Fix Version/s: 3.2.0-rc1

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Misha Tyulenev
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding B (10/30/15)
Participants:

 Description   

From https://github.com/mongodb/mongo/blob/r3.1.8/src/mongo/s/chunk_manager.cpp#L173

ChunkManager::ChunkManager(const CollectionType& coll)
    : _ns(coll.getNs().ns()),
      _keyPattern(coll.getKeyPattern()),
      _unique(coll.getUnique()),
      _sequenceNumber(NextSequenceNumber.addAndFetch(1)),
      _chunkRanges() {
    _version = ChunkVersion::fromBSON(coll.toBSON());
}

This looks suspicious as the config.collections does not contain any information about the highest (or any for that matter) chunk version of the collection.



 Comments   
Comment by Githook User [ 21/Oct/15 ]

Author:

{u'username': u'mikety', u'name': u'Misha Tyulenev', u'email': u'misha@mongodb.com'}

Message: SERVER-20548 init ChunkManager version to (0,0)
Branch: master
https://github.com/mongodb/mongo/commit/98c01ad3b4a3af2d2d2c156ed009cbd427b4eb85

Comment by Misha Tyulenev [ 20/Oct/15 ]

CR: https://mongodbcr.appspot.com/33030001/

Comment by Githook User [ 20/Oct/15 ]

Author:

{u'username': u'mikety', u'name': u'Misha Tyulenev', u'email': u'misha@mongodb.com'}

Message: SERVER-20548 init ChunkManager version to (0,0)
Branch: master
https://github.com/mongodb/mongo/commit/98c01ad3b4a3af2d2d2c156ed009cbd427b4eb85

Comment by Misha Tyulenev [ 16/Oct/15 ]

It does not look like a bug to me:
CollectionType::toBSON returns BSON e.g.

 { _id: "test.foo",
    lastmodEpoch: ObjectId('562171c9db1f6e1255969152'), 
    lastmod: new Date(4294967296), 
    dropped: false, 
    key: { shardkey2: 1.0, shardkey1: 1.0 }, 
    unique: false }

This string is parsed into valid chunk version by https://github.com/mongodb/mongo/blob/03c414e87e5c3bc34230421163cdd06c9451389d/src/mongo/s/chunk_version.h#L288-L311
The version is parsed from the Date number representation.

Comment by Randolph Tan [ 22/Sep/15 ]

I propose that the _version should be initialized with UNSHARDED instead of trying to extract from garbage. Also note the unnecessary toBSON call from a data type that was parsed from a BSON obj.

Comment by Andy Schwerin [ 22/Sep/15 ]

renctan, what do you want to do with this ticket?

Generated at Thu Feb 08 03:54:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.