diff options
-rw-r--r-- | src/mongo/s/writeback_listener.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/s/writeback_listener.cpp b/src/mongo/s/writeback_listener.cpp index 108a29567e3..c7d770ff9bb 100644 --- a/src/mongo/s/writeback_listener.cpp +++ b/src/mongo/s/writeback_listener.cpp @@ -140,6 +140,7 @@ namespace mongo { int secsToSleep = 0; scoped_ptr<ShardChunkVersion> lastNeededVersion; int lastNeededCount = 0; + bool needsToReloadShardInfo = false; while ( ! inShutdown() ) { @@ -150,6 +151,12 @@ namespace mongo { } try { + if (needsToReloadShardInfo) { + // It's possible this shard was removed + Shard::reloadShardInfo(); + needsToReloadShardInfo = false; + } + scoped_ptr<ScopedDbConnection> conn( ScopedDbConnection::getInternalScopedDbConnection( _addr ) ); @@ -401,6 +408,8 @@ namespace mongo { continue; } catch ( std::exception& e ) { + // Attention! Do not call any method that would throw an exception + // (or assert) in this block. if ( inShutdown() ) { // we're shutting down, so just clean up @@ -409,8 +418,7 @@ namespace mongo { log() << "WriteBackListener exception : " << e.what() << endl; - // It's possible this shard was removed - Shard::reloadShardInfo(); + needsToReloadShardInfo = true; } catch ( ... ) { log() << "WriteBackListener uncaught exception!" << endl; |