diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-08-02 15:17:24 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-08-02 15:17:24 -0400 |
commit | e53c67abab75e803dbab22d7a132321a722d32b9 (patch) | |
tree | 63ffa152acc5dc3bd282989681234d700fe99b70 | |
parent | a954509488bbc78ac963086565b66b3bd76aa582 (diff) | |
download | mongo-e53c67abab75e803dbab22d7a132321a722d32b9.tar.gz |
easier to disable last error for a short while SERVER-1541
-rw-r--r-- | db/lasterror.cpp | 2 | ||||
-rw-r--r-- | db/lasterror.h | 21 | ||||
-rw-r--r-- | s/chunk.cpp | 4 |
3 files changed, 23 insertions, 4 deletions
diff --git a/db/lasterror.cpp b/db/lasterror.cpp index a1de4c63d03..9fc5512e072 100644 --- a/db/lasterror.cpp +++ b/db/lasterror.cpp @@ -37,7 +37,7 @@ namespace mongo { /* might be intentional (non-user thread) */ OCCASIONALLY DEV if( !isShell ) log() << "warning dev: lastError==0 won't report:" << msg << endl; } else if ( le->disabled ) { - log() << "lastError disabled, can't report: " << msg << endl; + log() << "lastError disabled, can't report: " << code << ":" << msg << endl; } else { le->raiseError(code, msg); } diff --git a/db/lasterror.h b/db/lasterror.h index 6c1feacdfb7..b19a6cc8a39 100644 --- a/db/lasterror.h +++ b/db/lasterror.h @@ -71,6 +71,25 @@ namespace mongo { writebackId.clear(); } void appendSelf( BSONObjBuilder &b ); + + struct Disabled : boost::noncopyable { + Disabled( LastError * le ){ + _le = le; + if ( _le ){ + _prev = _le->disabled; + _le->disabled = true; + } + } + + ~Disabled(){ + if ( _le ) + _le->disabled = _prev; + } + + LastError * _le; + bool _prev; + }; + static LastError noError; }; @@ -121,7 +140,7 @@ namespace mongo { static mongo::mutex _idsmutex; map<int,Status> _ids; } lastError; - + void raiseError(int code , const char *msg); } // namespace mongo diff --git a/s/chunk.cpp b/s/chunk.cpp index c812a49e3fe..c2e0cc78e7c 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -197,8 +197,7 @@ namespace mongo { DistributedLock lockSetup( ConnectionString( modelServer() , ConnectionString::SYNC ) , getns() ); dist_lock_try dlk( &lockSetup , string("split-") + toString() ); - if ( ! dlk.got() ) - throw UserException( 10166 , "locking namespace failed" ); + uassert( 10166 , "locking namespace failed" , dlk.got() ); { ShardChunkVersion onServer = getVersionOnConfigServer(); @@ -334,6 +333,7 @@ namespace mongo { } bool Chunk::splitIfShould( long dataWritten ){ + LastError::Disabled d( lastError.get() ); try { return _splitIfShould( dataWritten ); } |