diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-08-08 12:11:28 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-08-08 12:20:43 -0400 |
commit | 4df93459d69b1536340047f9693f66763e001343 (patch) | |
tree | 2a41a698f5c17487c41c0c31655cb7ce4b51b7b6 /src/mongo | |
parent | ec23ec25b5b6aaae4611a87eee246c646df0361c (diff) | |
download | mongo-4df93459d69b1536340047f9693f66763e001343.tar.gz |
SERVER-14838: Fix shutdown failures
1. On Solaris, we race between the main thread, and signal thread. The
main thread wins, and returns EXIT_NET_ERROR. Previously, we use to work around
this by just sleeping on the main thread.
2. If we exit early due to missing db path, OperationContext asserts
because the storage engine has not been started yet.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/db.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 46 |
2 files changed, 27 insertions, 27 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 42bffd83de8..324209e4371 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -680,7 +680,7 @@ namespace mongo { try { _initAndListen(listenPort); - return EXIT_NET_ERROR; + return inShutdown() ? EXIT_CLEAN : EXIT_NET_ERROR; } catch ( DBException &e ) { log() << "exception in initAndListen: " << e.toString() << ", terminating" << endl; @@ -704,11 +704,7 @@ namespace mongo { ExitCode initService() { ntservice::reportStatus( SERVICE_RUNNING ); log() << "Service running" << endl; - ExitCode exitCode = initAndListen(serverGlobalParams.port); - - // ignore EXIT_NET_ERROR on clean shutdown since we return this when the listening socket - // is closed - return (exitCode == EXIT_NET_ERROR && inShutdown()) ? EXIT_CLEAN : exitCode; + return initAndListen(serverGlobalParams.port); } #endif diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 5411be70f75..467acddc96d 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -1008,30 +1008,34 @@ namespace { void exitCleanly( ExitCode code ) { shutdownInProgress.store(1); - getGlobalEnvironment()->setKillAllOperations(); + // Global storage engine may not be started in all cases before we exit + if (getGlobalEnvironment()->getGlobalStorageEngine() != NULL) { - repl::getGlobalReplicationCoordinator()->shutdown(); + getGlobalEnvironment()->setKillAllOperations(); - OperationContextImpl txn; - Lock::GlobalWrite lk(txn.lockState()); - log() << "now exiting" << endl; + repl::getGlobalReplicationCoordinator()->shutdown(); - // Execute the graceful shutdown tasks, such as flushing the outstanding journal and data - // files, close sockets, etc. - try { - shutdownServer(&txn); - } - catch (const DBException& ex) { - severe() << "shutdown failed with DBException " << ex; - std::terminate(); - } - catch (const std::exception& ex) { - severe() << "shutdown failed with std::exception: " << ex.what(); - std::terminate(); - } - catch (...) { - severe() << "shutdown failed with exception"; - std::terminate(); + OperationContextImpl txn; + Lock::GlobalWrite lk(txn.lockState()); + log() << "now exiting" << endl; + + // Execute the graceful shutdown tasks, such as flushing the outstanding journal + // and data files, close sockets, etc. + try { + shutdownServer(&txn); + } + catch (const DBException& ex) { + severe() << "shutdown failed with DBException " << ex; + std::terminate(); + } + catch (const std::exception& ex) { + severe() << "shutdown failed with std::exception: " << ex.what(); + std::terminate(); + } + catch (...) { + severe() << "shutdown failed with exception"; + std::terminate(); + } } dbexit( code ); |