Skip to content

Commit 30a1307

Browse files
author
Andy Schwerin
committed
SERVER-10172 Appenders must be added to global log domain during single threaded operation.
Due to an error during the logging refactoring, the RamLog("global") appender was being attached to the global log domain during the startup of the web server thread, rather than during mongo-initializer execution. MongoS and MongoD should both have been susceptible.
1 parent 06107f8 commit 30a1307

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/mongo/db/cmdline.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ namespace mongo {
128128
bool logWithSyslog; // True if logging to syslog; must not be set if logpath is set.
129129
std::string clusterAuthMode; // Cluster authentication mode
130130

131+
bool isHttpInterfaceEnabled; // True if the dbwebserver should be enabled.
132+
131133
#ifndef _WIN32
132134
ProcessId parentProc; // --fork pid of initial process
133135
ProcessId leaderProc; // --fork pid of leader process
@@ -196,7 +198,7 @@ namespace mongo {
196198
durOptions(0), objcheck(true), oplogSize(0), defaultProfile(0),
197199
slowMS(100), defaultLocalThresholdMillis(15), pretouch(0), moveParanoia( false ),
198200
syncdelay(60), noUnixSocket(false), doFork(0), socket("/tmp"), maxConns(DEFAULT_MAX_CONN),
199-
logAppend(false), logWithSyslog(false)
201+
logAppend(false), logWithSyslog(false), isHttpInterfaceEnabled(false)
200202
{
201203
started = time(0);
202204

src/mongo/db/db.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ namespace mongo {
104104

105105
CmdLine cmdLine;
106106
static bool scriptingEnabled = true;
107-
static bool httpInterface = false;
108107
bool shouldRepairDatabases = 0;
109108
static bool forceRepair = 0;
110109
Timer startupSrandTimer;
@@ -288,7 +287,7 @@ namespace mongo {
288287

289288
logStartup();
290289
startReplication();
291-
if ( httpInterface )
290+
if ( cmdLine.isHttpInterfaceEnabled )
292291
boost::thread web( boost::bind(&webServerThread, new RestAdminAccess() /* takes ownership */));
293292

294293
#if(TESTEXHAUST)
@@ -997,7 +996,7 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) {
997996
log() << "can't have both --httpinterface and --nohttpinterface" << endl;
998997
::_exit( EXIT_BADOPTIONS );
999998
}
1000-
httpInterface = true;
999+
cmdLine.isHttpInterfaceEnabled = true;
10011000
}
10021001
// SERVER-10019 Enabling rest/jsonp without --httpinterface should break in the future
10031002
if (params.count("rest")) {
@@ -1009,7 +1008,7 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) {
10091008
log() << "** WARNING: --rest is specified without --httpinterface," <<
10101009
startupWarningsLog;
10111010
log() << "** enabling http interface" << startupWarningsLog;
1012-
httpInterface = true;
1011+
cmdLine.isHttpInterfaceEnabled = true;
10131012
}
10141013
cmdLine.rest = true;
10151014
}
@@ -1022,7 +1021,7 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) {
10221021
log() << "** WARNING --jsonp is specified without --httpinterface," <<
10231022
startupWarningsLog;
10241023
log() << "** enabling http interface" << startupWarningsLog;
1025-
httpInterface = true;
1024+
cmdLine.isHttpInterfaceEnabled = true;
10261025
}
10271026
cmdLine.jsonp = true;
10281027
}

src/mongo/db/dbwebserver.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ namespace mongo {
329329
class LogPlugin : public WebStatusPlugin {
330330
public:
331331
LogPlugin() : WebStatusPlugin( "Log" , 100 ), _log(0) {
332-
}
333-
334-
virtual void init() {
335332
_log = RamLog::get( "global" );
336333
if ( ! _log ) {
337334
_log = new RamLog("global");
@@ -340,6 +337,9 @@ namespace mongo {
340337
}
341338
}
342339

340+
virtual void init() {
341+
}
342+
343343
virtual void run( stringstream& ss ) {
344344
_log->toHTML( ss );
345345
}
@@ -349,7 +349,9 @@ namespace mongo {
349349
MONGO_INITIALIZER_GENERAL(WebStatusLogPlugin, ("ServerLogRedirection"), ("default"))(
350350
InitializerContext*) {
351351

352-
new LogPlugin;
352+
if (cmdLine.isHttpInterfaceEnabled) {
353+
new LogPlugin;
354+
}
353355
return Status::OK();
354356
}
355357

src/mongo/s/server.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ namespace mongo {
8080
string mongosCommand;
8181
bool dbexitCalled = false;
8282
static bool scriptingEnabled = true;
83-
static bool httpInterface = false;
8483
static vector<string> configdbs;
8584

8685
bool inShutdown() {
@@ -335,7 +334,7 @@ static bool runMongosServer( bool doUpgrade ) {
335334
CmdLine::launchOk();
336335
#endif
337336

338-
if ( httpInterface )
337+
if ( cmdLine.isHttpInterfaceEnabled )
339338
boost::thread web( boost::bind(&webServerThread, new NoAdminAccess() /* takes ownership */) );
340339

341340
MessageServer::Options opts;
@@ -463,7 +462,7 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) {
463462
out() << "can't have both --httpinterface and --nohttpinterface" << endl;
464463
::_exit(EXIT_FAILURE);
465464
}
466-
httpInterface = true;
465+
cmdLine.isHttpInterfaceEnabled = true;
467466
}
468467

469468
if (params.count("noAutoSplit")) {

0 commit comments

Comments
 (0)