summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-12-02 15:17:19 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-12-02 15:17:19 -0500
commitd698427a79eed6538b16733463f34e70bcea6a1d (patch)
treea05e3c3ea091fff995900e52ce9d18a934bb19d8
parent389b5b48218f5ee73e4164afb84ea5fa2ba7646e (diff)
downloadmongo-d698427a79eed6538b16733463f34e70bcea6a1d.tar.gz
Revert "SERVER-14062 exitCleanly should not create OperationContext"
This reverts commit 15a2b7ca39ce472e43d8d37c6127eb4c3958456c.
-rw-r--r--src/mongo/db/instance.cpp14
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.h2
-rw-r--r--src/mongo/db/storage/in_memory/in_memory_engine.h2
-rw-r--r--src/mongo/db/storage/kv/kv_engine.h2
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.cpp4
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.h2
-rw-r--r--src/mongo/db/storage/rocks/rocks_engine.h2
-rw-r--r--src/mongo/db/storage/storage_engine.h2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp6
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h2
10 files changed, 21 insertions, 17 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 1590033eef2..5d0199aef9a 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -1024,7 +1024,10 @@ namespace {
return shutdownInProgress.loadRelaxed() != 0;
}
- static void shutdownServer() {
+ static void shutdownServer(OperationContext* txn) {
+ // Must hold global lock to get to here
+ invariant(txn->lockState()->isW());
+
log(LogComponent::kNetwork) << "shutdown: going to close listening sockets..." << endl;
ListeningSockets::get()->closeAll();
@@ -1036,7 +1039,7 @@ namespace {
boost::thread close_socket_thread( stdx::bind(MessagingPort::closeAllSockets, 0) );
StorageEngine* storageEngine = getGlobalEnvironment()->getGlobalStorageEngine();
- storageEngine->cleanShutdown();
+ storageEngine->cleanShutdown(txn);
}
void exitCleanly(ExitCode code) {
@@ -1052,19 +1055,20 @@ namespace {
invariant(false);
}
+ OperationContextImpl txn;
+
getGlobalEnvironment()->setKillAllOperations();
repl::getGlobalReplicationCoordinator()->shutdown();
- OperationContextImpl txn;
+ ScopedTransaction transaction(&txn, MODE_X);
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();
+ shutdownServer(&txn);
}
catch (const DBException& ex) {
severe() << "shutdown failed with DBException " << ex;
diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.h b/src/mongo/db/storage/devnull/devnull_kv_engine.h
index 473dcebfbab..6539fb9014a 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.h
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h
@@ -92,7 +92,7 @@ namespace mongo {
return std::vector<std::string>();
}
- virtual void cleanShutdown() {};
+ virtual void cleanShutdown(OperationContext* txn) {};
private:
boost::shared_ptr<void> _catalogInfo;
diff --git a/src/mongo/db/storage/in_memory/in_memory_engine.h b/src/mongo/db/storage/in_memory/in_memory_engine.h
index 0c913cf8296..c4f821dbb9d 100644
--- a/src/mongo/db/storage/in_memory/in_memory_engine.h
+++ b/src/mongo/db/storage/in_memory/in_memory_engine.h
@@ -78,7 +78,7 @@ namespace mongo {
return Status::OK();
}
- virtual void cleanShutdown() {};
+ virtual void cleanShutdown(OperationContext* txn) {};
std::vector<std::string> getAllIdents( OperationContext* opCtx ) const;
private:
diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h
index 9f343e1238c..1ff79bca388 100644
--- a/src/mongo/db/storage/kv/kv_engine.h
+++ b/src/mongo/db/storage/kv/kv_engine.h
@@ -119,7 +119,7 @@ namespace mongo {
*
* There is intentionally no uncleanShutdown().
*/
- virtual void cleanShutdown() = 0;
+ virtual void cleanShutdown(OperationContext* txn) = 0;
/**
* The destructor will never be called from mongod, but may be called from tests.
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp
index a1ec8b1e53c..1928cc6008e 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.cpp
+++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp
@@ -151,7 +151,7 @@ namespace mongo {
}
- void KVStorageEngine::cleanShutdown() {
+ void KVStorageEngine::cleanShutdown(OperationContext* txn) {
for ( DBMap::const_iterator it = _dbs.begin(); it != _dbs.end(); ++it ) {
delete it->second;
@@ -161,7 +161,7 @@ namespace mongo {
_catalog.reset( NULL );
_catalogRecordStore.reset( NULL );
- _engine->cleanShutdown();
+ _engine->cleanShutdown(txn);
// intentionally not deleting _engine
}
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h
index 5e52ca1c3a0..669d163520b 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.h
+++ b/src/mongo/db/storage/kv/kv_storage_engine.h
@@ -88,7 +88,7 @@ namespace mongo {
bool preserveClonedFilesOnFailure = false,
bool backupOriginalFiles = false );
- virtual void cleanShutdown();
+ virtual void cleanShutdown(OperationContext* txn);
// ------ kv ------
diff --git a/src/mongo/db/storage/rocks/rocks_engine.h b/src/mongo/db/storage/rocks/rocks_engine.h
index ca8ef727325..a31a9aedf2d 100644
--- a/src/mongo/db/storage/rocks/rocks_engine.h
+++ b/src/mongo/db/storage/rocks/rocks_engine.h
@@ -109,7 +109,7 @@ namespace mongo {
return Status::OK();
}
- virtual void cleanShutdown() {}
+ virtual void cleanShutdown(OperationContext* txn) {}
// rocks specific api
diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h
index f035d220cd6..63912c6bd0c 100644
--- a/src/mongo/db/storage/storage_engine.h
+++ b/src/mongo/db/storage/storage_engine.h
@@ -160,7 +160,7 @@ namespace mongo {
*
* There is intentionally no uncleanShutdown().
*/
- virtual void cleanShutdown() {}
+ virtual void cleanShutdown(OperationContext* txn) {}
protected:
/**
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index f44009b6cbe..730aee022d1 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -166,7 +166,7 @@ namespace mongo {
WiredTigerKVEngine::~WiredTigerKVEngine() {
if (_conn) {
- cleanShutdown();
+ cleanShutdown(NULL); // our impl doesn't use the OperationContext
}
_sizeStorer.reset( NULL );
@@ -175,7 +175,7 @@ namespace mongo {
}
- void WiredTigerKVEngine::cleanShutdown() {
+ void WiredTigerKVEngine::cleanShutdown(OperationContext* txn) {
log() << "WiredTigerKVEngine shutting down";
syncSizeInfo(true);
if (_conn) {
@@ -236,7 +236,7 @@ namespace mongo {
_sizeStorer->storeInto( &session, _sizeStorerUri );
invariantWTOK( s->commit_transaction( s, NULL ) );
}
- catch (const WriteConflictException&) {
+ catch ( const WriteConflictException& de ) {
// ignore, it means someone else is doing it
}
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
index 44693348581..2f7977ac527 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
@@ -101,7 +101,7 @@ namespace mongo {
std::vector<std::string> getAllIdents( OperationContext* opCtx ) const;
- virtual void cleanShutdown();
+ virtual void cleanShutdown(OperationContext* txn);
// wiredtiger specific
// Calls WT_CONNECTION::reconfigure on the underlying WT_CONNECTION