Brian M
Brian M

Reputation: 85

Configuring the number of config server retries on mongos start?

I'm attempting to start mongos and fail fast if the config server is unavailable. Right now, with an unavailable config server, I'm seeing:

Tue Feb 12 11:09:13 [mongosMain] can't resolve DNS for [compute-1-3] sleeping and trying 10 more times

How do I configure the 10?

Upvotes: 1

Views: 407

Answers (1)

Adam Comerford
Adam Comerford

Reputation: 21682

The 10 retries is hard coded, it is not configurable. You can see it here:

https://github.com/mongodb/mongo/blob/master/src/mongo/s/config.cpp#L742

Just in case line numbers change, here's the relevant counter/loop:

for ( int x=10; x>0; x-- ) {
                if ( ! hostbyname( host.c_str() ).empty() ) {
                    ok = true;
                    break;
                }
                log() << "can't resolve DNS for [" << host << "]  sleeping and trying " << x << " more times" << endl;
                sleepsecs( 10 );

Therefore you could, in theory, alter the code and re-build yourself, but then you would have to maintain that for new versions. I would recommend instead that you keep the config server available instead, or at least have it up within ~100 seconds of the mongos starting.

Upvotes: 1

Related Questions