Skip to content

Commit

Permalink
buildbot sharding_balance4.js explicitly report chunk manager sequenc…
Browse files Browse the repository at this point in the history
…e number when available in setShardVersion
  • Loading branch information
Greg Studer committed Oct 19, 2012
1 parent fd3f282 commit 3cbe374
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/mongo/s/chunk.cpp
Expand Up @@ -1253,8 +1253,15 @@ namespace mongo {
// we need a special command for dropping on the d side
// this hack works for the moment

if ( ! setShardVersion( conn->conn(), _ns, ShardChunkVersion( 0, OID() ), true, res ) )
if ( ! setShardVersion( conn->conn(),
_ns,
ShardChunkVersion( 0, OID() ),
ChunkManagerPtr(),
true, res ) )
{
throw UserException( 8071 , str::stream() << "cleaning up after drop failed: " << res );
}

conn->get()->simpleCommand( "admin", 0, "unsetSharding" );
conn->done();
}
Expand Down Expand Up @@ -1417,7 +1424,13 @@ namespace mongo {
// NOTE (careful when deprecating)
// currently the sharding is enabled because of a write or read (as opposed to a split or migrate), the shard learns
// its name and through the 'setShardVersion' command call
bool setShardVersion( DBClientBase & conn , const string& ns , ShardChunkVersion version , bool authoritative , BSONObj& result ) {
bool setShardVersion( DBClientBase & conn,
const string& ns,
ShardChunkVersion version,
ChunkManagerPtr manager, // Used only for reporting!
bool authoritative ,
BSONObj& result )
{
BSONObjBuilder cmdBuilder;
cmdBuilder.append( "setShardVersion" , ns.c_str() );
cmdBuilder.append( "configdb" , configServer.modelServer() );
Expand All @@ -1431,7 +1444,14 @@ namespace mongo {
cmdBuilder.append( "shardHost" , s.getConnString() );
BSONObj cmd = cmdBuilder.obj();

LOG(1) << " setShardVersion " << s.getName() << " " << conn.getServerAddress() << " " << ns << " " << cmd << " " << &conn << endl;
LOG(1) << " setShardVersion " << s.getName()
<< " " << conn.getServerAddress()
<< " " << ns
<< " " << cmd
<< " " << &conn
<< (manager.get() ? string(str::stream() << " " << manager->getSequenceNumber()) :
"")
<< endl;

return conn.runCommand( "admin",
cmd,
Expand Down
7 changes: 6 additions & 1 deletion src/mongo/s/chunk.h
Expand Up @@ -555,6 +555,11 @@ namespace mongo {
*/
inline string Chunk::genID() const { return genID(_manager->getns(), _min); }

bool setShardVersion( DBClientBase & conn , const string& ns , ShardChunkVersion version , bool authoritative , BSONObj& result );
bool setShardVersion( DBClientBase & conn,
const string& ns,
ShardChunkVersion version,
ChunkManagerPtr manager,
bool authoritative,
BSONObj& result );

} // namespace mongo
2 changes: 1 addition & 1 deletion src/mongo/s/shard_version.cpp
Expand Up @@ -235,7 +235,7 @@ namespace mongo {
const string versionableServerAddress(conn->getServerAddress());

BSONObj result;
if ( setShardVersion( *conn , ns , version , authoritative , result ) ) {
if ( setShardVersion( *conn , ns , version , manager , authoritative , result ) ) {
// success!
LOG(1) << " setShardVersion success: " << result << endl;
connectionShardStatus.setSequence( conn , ns , officialSequenceNumber );
Expand Down

0 comments on commit 3cbe374

Please sign in to comment.