summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2017-11-10 12:05:18 -0500
committerEric Milkie <milkie@10gen.com>2017-11-13 12:54:15 -0500
commit9a1f209aa8e47587af6ad81e991b101abea1f677 (patch)
tree4807f654de7e30062bcf2c5fb4a4cb19094fc04d /src/mongo
parent41c49040533745389fa0c75e7a4abd2fe430acc7 (diff)
downloadmongo-9a1f209aa8e47587af6ad81e991b101abea1f677.tar.gz
SERVER-31912 use a private WT_SESSION in waitUntilDurable instead of one from the session cache
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp12
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index 11cd1594b02..90d9dff9f08 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -250,20 +250,24 @@ void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint, bool stableC
_lastSyncTime.store(current + 1);
// Nobody has synched yet, so we have to sync ourselves.
- auto session = getSession();
- WT_SESSION* s = session->getSession();
// This gets the token (OpTime) from the last write, before flushing (either the journal, or a
// checkpoint), and then reports that token (OpTime) as a durable write.
stdx::unique_lock<stdx::mutex> jlk(_journalListenerMutex);
JournalListener::Token token = _journalListener->getToken();
+ // Initialize on first use.
+ if (!_waitUntilDurableSession) {
+ invariantWTOK(
+ _conn->open_session(_conn, NULL, "isolation=snapshot", &_waitUntilDurableSession));
+ }
+
// Use the journal when available, or a checkpoint otherwise.
if (_engine && _engine->isDurable()) {
- invariantWTOK(s->log_flush(s, "sync=on"));
+ invariantWTOK(_waitUntilDurableSession->log_flush(_waitUntilDurableSession, "sync=on"));
LOG(4) << "flushed journal";
} else {
- invariantWTOK(s->checkpoint(s, NULL));
+ invariantWTOK(_waitUntilDurableSession->checkpoint(_waitUntilDurableSession, NULL));
LOG(4) << "created checkpoint";
}
_journalListener->onDurable(token);
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
index 5f8045ee2de..12c61fb0db3 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
@@ -248,6 +248,9 @@ private:
// Notified when we commit to the journal.
JournalListener* _journalListener = &NoOpJournalListener::instance;
+ WT_SESSION* _waitUntilDurableSession = nullptr; // owned, and never explicitly closed
+ // (uses connection close to clean up)
+
/**
* Returns a session to the cache for later reuse. If closeAll was called between getting this
* session and releasing it, the session is directly released. This method is thread safe.