summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelsey Schubert <kelsey@mongodb.com>2018-03-12 12:03:01 -0400
committerKelsey Schubert <kelsey@mongodb.com>2018-03-12 13:58:29 -0400
commitc3860652ccb14862b132d95df4f034230c7423e1 (patch)
tree1389cfdace709788099d7ce5c5f843d97d24f561
parentae5f57d8ec48f2c877c3b841068a830db5eb874f (diff)
downloadmongo-c3860652ccb14862b132d95df4f034230c7423e1.tar.gz
SERVER-32876 Don't stall ftdc due to WT cache full
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp4
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp7
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h9
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp1
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp8
7 files changed, 32 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 4d1d0a8faab..7761857bf90 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -909,7 +909,7 @@ int64_t WiredTigerRecordStore::storageSize(OperationContext* txn,
if (_isEphemeral) {
return dataSize(txn);
}
- WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSession(txn);
+ WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSessionNoTxn(txn);
StatusWith<int64_t> result =
WiredTigerUtil::getStatisticsValueAs<int64_t>(session->getSession(),
"statistics:" + getURI(),
@@ -1628,7 +1628,7 @@ void WiredTigerRecordStore::appendCustomStats(OperationContext* txn,
result->appendIntOrLL("sleepCount", _cappedSleep.load());
result->appendIntOrLL("sleepMS", _cappedSleepMS.load());
}
- WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSession(txn);
+ WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSessionNoTxn(txn);
WT_SESSION* s = session->getSession();
BSONObjBuilder bob(result->subobjStart(_engineName));
{
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index 1296bb3d84e..fe35bd07651 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -43,6 +43,7 @@
#include "mongo/util/concurrency/ticketholder.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/scopeguard.h"
#include "mongo/util/stacktrace.h"
namespace mongo {
@@ -172,7 +173,12 @@ WiredTigerSession* WiredTigerRecoveryUnit::getSession(OperationContext* opCtx) {
WiredTigerSession* WiredTigerRecoveryUnit::getSessionNoTxn(OperationContext* opCtx) {
_ensureSession();
- return _session.get();
+ WiredTigerSession* session = _session.get();
+
+ // Dropping the queued idents might block session, which is not desired for fastpath workflow
+ // like FTDC thread. Disable dropping of queued idents for such sessions.
+ session->dropQueuedIdentsAtSessionEndAllowed(false);
+ return session;
}
void WiredTigerRecoveryUnit::abandonSnapshot() {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index d29186db578..9df6ba94651 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -357,6 +357,11 @@ void WiredTigerSessionCache::releaseSession(WiredTigerSession* session) {
bool returnedToCache = false;
uint64_t currentEpoch = _epoch.load();
+ bool dropQueuedIdentsAtSessionEnd = session->isDropQueuedIdentsAtSessionEndAllowed();
+
+ // Reset this session's flag for dropping queued idents to default, before returning it to
+ // session cache.
+ session->dropQueuedIdentsAtSessionEndAllowed(true);
if (session->_getEpoch() == currentEpoch) { // check outside of lock to reduce contention
stdx::lock_guard<stdx::mutex> lock(_cacheLock);
@@ -370,7 +375,7 @@ void WiredTigerSessionCache::releaseSession(WiredTigerSession* session) {
if (!returnedToCache)
delete session;
- if (_engine && _engine->haveDropsQueued())
+ if (dropQueuedIdentsAtSessionEnd && _engine && _engine->haveDropsQueued())
_engine->dropSomeQueuedIdents();
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
index 26ec9934fcf..34c05a3304b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
@@ -109,6 +109,14 @@ public:
return _cursorsOut;
}
+ bool isDropQueuedIdentsAtSessionEndAllowed() const {
+ return _dropQueuedIdentsAtSessionEnd;
+ }
+
+ void dropQueuedIdentsAtSessionEndAllowed(bool dropQueuedIdentsAtSessionEnd) {
+ _dropQueuedIdentsAtSessionEnd = dropQueuedIdentsAtSessionEnd;
+ }
+
static uint64_t genTableId();
/**
@@ -139,6 +147,7 @@ private:
CursorCache _cursors; // owned
uint64_t _cursorGen;
int _cursorsOut;
+ bool _dropQueuedIdentsAtSessionEnd = true;
};
/**
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
index 7783cea4cbf..bab41079a9b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
@@ -202,7 +202,7 @@ void WiredTigerSizeStorer::syncCache(bool syncToDisk) {
WT_SESSION* session = _session.getSession();
invariantWTOK(session->begin_transaction(session, syncToDisk ? "sync=true" : ""));
- ScopeGuard rollbacker = MakeGuard(session->rollback_transaction, session, "");
+ auto rollbacker = MakeGuard(session->rollback_transaction, session, "");
for (Map::iterator it = myMap.begin(); it != myMap.end(); ++it) {
string uriKey = it->first;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp
index da0f618f1bd..e6000e62604 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
index f00b4a33804..c0f0907f8da 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
@@ -103,9 +103,13 @@ void WiredTigerUtil::fetchTypeAndSourceURI(OperationContext* opCtx,
StatusWith<std::string> WiredTigerUtil::getMetadata(OperationContext* opCtx, StringData uri) {
invariant(opCtx);
- WiredTigerCursor curwrap("metadata:create", WiredTigerSession::kMetadataTableId, false, opCtx);
- WT_CURSOR* cursor = curwrap.get();
+
+ auto session = WiredTigerRecoveryUnit::get(opCtx)->getSessionNoTxn(opCtx);
+ WT_CURSOR* cursor =
+ session->getCursor("metadata:create", WiredTigerSession::kMetadataTableId, false);
invariant(cursor);
+ ON_BLOCK_EXIT([&] { session->releaseCursor(WiredTigerSession::kMetadataTableId, cursor); });
+
std::string strUri = uri.toString();
cursor->set_key(cursor, strUri.c_str());
int ret = cursor->search(cursor);