diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2018-09-12 16:08:54 -0400 |
---|---|---|
committer | Samy Lanka <samy.lanka@mongodb.com> | 2018-09-13 16:36:48 -0400 |
commit | bd38c69f5e6dc3136d20505d49f034c0927bf3e2 (patch) | |
tree | 236c1771bcc404cd0058a1057e369bf5b3c2bc80 /src | |
parent | 022c7d50ac5f7f62fd4e91df513baa56d011fc80 (diff) | |
download | mongo-bd38c69f5e6dc3136d20505d49f034c0927bf3e2.tar.gz |
SERVER-36726 Log SessionID when we start a session in the shell and Log TxnNumber when we start a transaction
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/session.cpp | 6 | ||||
-rw-r--r-- | src/mongo/shell/mongo.js | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp index d541ec708d4..34f58c56ecc 100644 --- a/src/mongo/db/session.cpp +++ b/src/mongo/db/session.cpp @@ -27,7 +27,8 @@ */ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage - +#define LOG_FOR_TRANSACTION(level) \ + MONGO_LOG_COMPONENT(level, ::mongo::logger::LogComponent::kTransaction) #include "mongo/platform/basic.h" #include "mongo/db/session.h" @@ -435,6 +436,9 @@ void Session::_beginOrContinueTxn(WithLock wl, TxnNumber txnNumber) { invariant(txnNumber > _activeTxnNumber); _setActiveTxn(wl, txnNumber); + + LOG_FOR_TRANSACTION(4) << "New transaction started with txnNumber: " << txnNumber + << " on session with lsid " << getSessionId().getId(); } void Session::_checkTxnValid(WithLock, TxnNumber txnNumber) const { diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js index 416416d8b3f..4db8924a8ec 100644 --- a/src/mongo/shell/mongo.js +++ b/src/mongo/shell/mongo.js @@ -441,7 +441,15 @@ Mongo.prototype.startSession = function startSession(options = {}) { if (!options.hasOwnProperty("retryWrites") && this.hasOwnProperty("_retryWrites")) { options.retryWrites = this._retryWrites; } - return new DriverSession(this, options); + const newDriverSession = new DriverSession(this, options); + + // Only log this message if we are running a test + if (typeof TestData === "object" && TestData.testName) { + jsTest.log("New session started with sessionID: " + + tojson(newDriverSession.getSessionId())); + } + + return newDriverSession; }; Mongo.prototype._getDefaultSession = function getDefaultSession() { |