From 1e5ccf29c485109c22338fda2c8c46bf1c600f87 Mon Sep 17 00:00:00 2001 From: Matt Kangas Date: Mon, 27 Oct 2014 17:04:23 -0400 Subject: SERVER-15627 Use LogComponent::kWrites where appropriate --- .../db/commands/write_commands/batch_executor.cpp | 2 +- src/mongo/db/exec/delete.cpp | 2 +- src/mongo/db/exec/update.cpp | 2 +- src/mongo/db/instance.cpp | 33 +++++++++++++++------- src/mongo/db/ops/delete_executor.cpp | 2 +- src/mongo/db/ops/update.cpp | 2 +- src/mongo/db/ops/update_executor.cpp | 2 +- src/mongo/db/ops/update_result.cpp | 2 +- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index e3d2c228dd8..bcbf68d8ba9 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -26,7 +26,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommands +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp index f4633af95a8..a92b98c04c8 100644 --- a/src/mongo/db/exec/delete.cpp +++ b/src/mongo/db/exec/delete.cpp @@ -26,7 +26,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/exec/update.cpp b/src/mongo/db/exec/update.cpp index c3a44531f7b..e3ece80865a 100644 --- a/src/mongo/db/exec/update.cpp +++ b/src/mongo/db/exec/update.cpp @@ -26,7 +26,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 114f8d74ba8..920589d07f4 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -91,6 +91,19 @@ namespace mongo { using logger::LogComponent; +namespace { + inline LogComponent logComponentForOp(int op) { + switch (op) { + case dbInsert: + case dbUpdate: + case dbDelete: + return LogComponent::kWrites; + default: + return LogComponent::kQuery; + } + } +} // namespace + // for diaglog inline void opread(Message& m) { if (_diaglog.getLevel() & 2) { @@ -515,14 +528,14 @@ namespace mongo { } catch (const UserException& ue) { setLastError(ue.getCode(), ue.getInfo().msg.c_str()); - MONGO_LOG_COMPONENT(3, LogComponent::kQuery) + MONGO_LOG_COMPONENT(3, logComponentForOp(op)) << " Caught Assertion in " << opToString(op) << ", continuing " << ue.toString() << endl; debug.exceptionInfo = ue.getInfo(); } catch (const AssertionException& e) { setLastError(e.getCode(), e.getInfo().msg.c_str()); - MONGO_LOG_COMPONENT(3, LogComponent::kQuery) + MONGO_LOG_COMPONENT(3, logComponentForOp(op)) << " Caught Assertion in " << opToString(op) << ", continuing " << e.toString() << endl; debug.exceptionInfo = e.getInfo(); @@ -536,18 +549,18 @@ namespace mongo { logThreshold += currentOp.getExpectedLatencyMs(); if ( shouldLog || debug.executionTime > logThreshold ) { - MONGO_LOG_COMPONENT(0, LogComponent::kQuery) + MONGO_LOG_COMPONENT(0, logComponentForOp(op)) << debug.report( currentOp ) << endl; } if ( currentOp.shouldDBProfile( debug.executionTime ) ) { // performance profiling is on if (txn->lockState()->hasAnyReadLock()) { - MONGO_LOG_COMPONENT(1, LogComponent::kQuery) + MONGO_LOG_COMPONENT(1, logComponentForOp(op)) << "note: not profiling because recursive read lock" << endl; } else if ( lockedForWriting() ) { - MONGO_LOG_COMPONENT(1, LogComponent::kQuery) + MONGO_LOG_COMPONENT(1, logComponentForOp(op)) << "note: not profiling because doing fsync+lock" << endl; } else { @@ -645,12 +658,12 @@ namespace mongo { } catch ( const DeadLockException& dle ) { if ( multi ) { - log() << "got deadlock during multi update, aborting"; + log(LogComponent::kWrites) << "got deadlock during multi update, aborting"; throw; } else { - log() << "got deadlock doing update on " << ns - << ", attempt: " << attempt++ << " retrying"; + log(LogComponent::kWrites) << "got deadlock doing update on " << ns + << ", attempt: " << attempt++ << " retrying"; } } } @@ -720,8 +733,8 @@ namespace mongo { return; } catch ( const DeadLockException& dle ) { - log() << "got deadlock doing insert on " << ns - << ", attempt: " << attempt++ << " retrying"; + log(LogComponent::kWrites) << "got deadlock doing delete on " << ns + << ", attempt: " << attempt++ << " retrying"; } } } diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp index aa7515d9f44..b66f153dac1 100644 --- a/src/mongo/db/ops/delete_executor.cpp +++ b/src/mongo/db/ops/delete_executor.cpp @@ -26,7 +26,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp index 435d4104df6..aa7d41c1be8 100644 --- a/src/mongo/db/ops/update.cpp +++ b/src/mongo/db/ops/update.cpp @@ -28,7 +28,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/ops/update_executor.cpp b/src/mongo/db/ops/update_executor.cpp index d6e93049a1d..2975b67f745 100644 --- a/src/mongo/db/ops/update_executor.cpp +++ b/src/mongo/db/ops/update_executor.cpp @@ -26,7 +26,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" diff --git a/src/mongo/db/ops/update_result.cpp b/src/mongo/db/ops/update_result.cpp index e20dc451089..bcbe22a0312 100644 --- a/src/mongo/db/ops/update_result.cpp +++ b/src/mongo/db/ops/update_result.cpp @@ -28,7 +28,7 @@ * it in the license file. */ -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrites #include "mongo/platform/basic.h" -- cgit v1.2.1