diff options
author | Randolph Tan <randolph@10gen.com> | 2012-12-13 12:01:22 -0500 |
---|---|---|
committer | Dan Pasette <dan@10gen.com> | 2013-05-19 09:39:44 -0700 |
commit | aa141a8f086230a25161299f685f9bd3c710936d (patch) | |
tree | 1e4bd6dc564ce0b33fecccbeaaa8ce804fae3f71 | |
parent | 90bca9c3ad719d3070fe1c94dc3a716aff63bb3c (diff) | |
download | mongo-aa141a8f086230a25161299f685f9bd3c710936d.tar.gz |
SERVER-7771 WritebackListener thread can die while handling exceptions
-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; |