summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp4
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp7
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h6
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp3
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h8
5 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 3ed0b96f6df..fe901ab79cd 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -1192,7 +1192,9 @@ bool WiredTigerRecordStore::yieldAndAwaitOplogDeletionRequest(OperationContext*
// The top-level locks were freed, so also release any potential low-level (storage engine)
// locks that might be held.
- txn->recoveryUnit()->abandonSnapshot();
+ WiredTigerRecoveryUnit* recoveryUnit = (WiredTigerRecoveryUnit*)txn->recoveryUnit();
+ recoveryUnit->abandonSnapshot();
+ recoveryUnit->beginIdle();
// Wait for an oplog deletion request, or for this record store to have been destroyed.
oplogStones->awaitHasExcessStonesOrDead();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index 6e2d6643d92..86f0fbf835f 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -257,6 +257,13 @@ void WiredTigerRecoveryUnit::_txnOpen(OperationContext* opCtx) {
_active = true;
}
+void WiredTigerRecoveryUnit::beginIdle() {
+ // Close all cursors, we don't want to keep any old cached cursors around.
+ if (_session) {
+ _session->closeAllCursors("");
+ }
+}
+
// ---------------------
WiredTigerCursor::WiredTigerCursor(const std::string& uri,
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
index 9b486c5893a..216595c9b06 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
@@ -84,6 +84,12 @@ public:
WiredTigerSession* getSession(OperationContext* opCtx);
/**
+ * Enter a period of wait or computation during which there are no WT calls.
+ * Any non-relevant cached handles can be closed.
+ */
+ void beginIdle();
+
+ /**
* Returns a session without starting a new WT txn on the session. Will not close any already
* running session.
*/
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index cb1282a6790..caf3efe4ac9 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -109,9 +109,10 @@ void WiredTigerSession::releaseCursor(uint64_t id, WT_CURSOR* cursor) {
void WiredTigerSession::closeAllCursors(const std::string& uri) {
invariant(_session);
+ bool all = (uri == "");
for (auto i = _cursors.begin(); i != _cursors.end();) {
WT_CURSOR* cursor = i->_cursor;
- if (cursor && uri == cursor->uri) {
+ if (cursor && (all || uri == cursor->uri)) {
invariantWTOK(cursor->close(cursor));
i = _cursors.erase(i);
} else
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
index b0030fe5f20..072ab459242 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
@@ -85,6 +85,10 @@ public:
void closeCursorsForQueuedDrops(uint64_t cursorEpoch, WiredTigerKVEngine* engine);
+ /**
+ * Closes all cached cursors matching the uri. If the uri is empty,
+ * all cached cursors are closed.
+ */
void closeAllCursors(const std::string& uri);
int cursorsOut() const {
@@ -157,8 +161,8 @@ public:
void closeCursorsForQueuedDrops();
/**
- * Closes all cached cursors and ensures that previously opened cursors will be closed on
- * release.
+ * Closes all cached cursors matching the uri. If the uri is empty,
+ * all cached cursors are closed.
*/
void closeAllCursors(const std::string& uri);