diff options
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/write_conflict_exception.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/concurrency/write_conflict_exception.h | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/write_conflict_exception.cpp b/src/mongo/db/concurrency/write_conflict_exception.cpp index 7870a721056..7e6e9d08c75 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.cpp +++ b/src/mongo/db/concurrency/write_conflict_exception.cpp @@ -32,9 +32,21 @@ #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/util/log.h" +#include "mongo/util/stacktrace.h" namespace mongo { + bool WriteConflictException::trace = false; + + WriteConflictException::WriteConflictException() + : DBException( "WriteConflict", ErrorCodes::WriteConflict ) { + + if ( trace ) { + printStackTrace(); + } + + } + void WriteConflictException::logAndBackoff(int attempt, const StringData& operation, const StringData& ns) { diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index 6313b780adb..a2d016a80db 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -43,7 +43,7 @@ namespace mongo { */ class WriteConflictException : public DBException { public: - WriteConflictException() : DBException( "WriteConflict", ErrorCodes::WriteConflict ){} + WriteConflictException(); /** * Will log a message if sensible and will do an exponential backoff to make sure @@ -54,6 +54,12 @@ namespace mongo { static void logAndBackoff(int attempt, const StringData& operation, const StringData& ns); + + /** + * If true, will call printStackTrace on every WriteConflictException created. + * Can be set via setParameter named traceWriteConflictExceptions. + */ + static bool trace; }; } |