~ubuntu-branches/ubuntu/wily/juju-mongodb/wily-proposed

« back to all changes in this revision

Viewing changes to src/mongo/s/version_manager.cpp

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-22 14:52:36 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140122145236-exgvx1pxk4fu9o4c
Tags: 2.4.9-0ubuntu1
* New upstream point release.
* d/p/0003-SERVER-12064-Use-gcc-atomic-builtins-if-available.patch:
  Dropped - not really needed for this version on mongodb.
* d/install: Don't ship mongo binary, its broken without a JS engine
  (LP: #1270098).
* d/p/0005-disable-jstests.patch: Dropped in preference to updates to
  d/p/0001-Add-option-to-disable-javascript.patch - rebased on revised
  upstream pull request.
* d/rules: Don't strip binaries during build so we get a ddeb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
        WriteBackListener::init( *conn_in );
105
105
 
106
 
        DBClientBase* conn = getVersionable( conn_in );
107
 
        verify( conn ); // errors thrown above
108
 
 
109
 
        BSONObjBuilder cmdBuilder;
110
 
 
111
 
        cmdBuilder.append( "setShardVersion" , "" );
112
 
        cmdBuilder.appendBool( "init", true );
113
 
        cmdBuilder.append( "configdb" , configServer.modelServer() );
114
 
        cmdBuilder.appendOID( "serverID" , &serverID );
115
 
        cmdBuilder.appendBool( "authoritative" , true );
116
 
 
117
 
        BSONObj cmd = cmdBuilder.obj();
118
 
 
119
 
        LOG(1) << "initializing shard connection to " << conn->toString() << endl;
120
 
        LOG(2) << "initial sharding settings : " << cmd << endl;
121
 
 
122
 
        bool ok = conn->runCommand("admin", cmd, result, 0);
 
106
        bool ok;
 
107
        DBClientBase* conn = NULL;
 
108
        try {
 
109
            // May throw if replica set primary is down
 
110
            conn = getVersionable( conn_in );
 
111
            dassert( conn ); // errors thrown above
 
112
 
 
113
            BSONObjBuilder cmdBuilder;
 
114
 
 
115
            cmdBuilder.append( "setShardVersion" , "" );
 
116
            cmdBuilder.appendBool( "init", true );
 
117
            cmdBuilder.append( "configdb" , configServer.modelServer() );
 
118
            cmdBuilder.appendOID( "serverID" , &serverID );
 
119
            cmdBuilder.appendBool( "authoritative" , true );
 
120
 
 
121
            BSONObj cmd = cmdBuilder.obj();
 
122
 
 
123
            LOG(1) << "initializing shard connection to " << conn->toString() << endl;
 
124
            LOG(2) << "initial sharding settings : " << cmd << endl;
 
125
 
 
126
            ok = conn->runCommand("admin", cmd, result, 0);
 
127
        }
 
128
        catch( const DBException& ex ) {
 
129
 
 
130
            bool ignoreFailure = ShardConnection::ignoreInitialVersionFailure
 
131
                                 && conn_in->type() == ConnectionString::SET;
 
132
            if ( !ignoreFailure )
 
133
                throw;
 
134
 
 
135
            // Using initShardVersion is not strictly required when talking to replica sets - it is
 
136
            // preferred to do so because it registers mongos early with the mongod.  This info is
 
137
            // also sent by checkShardVersion before a connection is used for a write or read.
 
138
 
 
139
            OCCASIONALLY {
 
140
                warning() << "failed to initialize new replica set connection version, "
 
141
                          << "will initialize on first use" << endl;
 
142
            }
 
143
 
 
144
            return true;
 
145
        }
123
146
 
124
147
        // HACK for backwards compatibility with v1.8.x, v2.0.0 and v2.0.1
125
148
        // Result is false, but will still initialize serverID and configdb