![]() |
Storage Engine API
|
This cache implements a shared pool of WiredTiger sessions with the goal to amortize the cost of session creation and destruction over multiple uses. More...
#include <wiredtiger_session_cache.h>
This cache implements a shared pool of WiredTiger sessions with the goal to amortize the cost of session creation and destruction over multiple uses.
Classes | |
class | WiredTigerSessionDeleter |
This deleter automatically releases WiredTigerSession objects when no longer needed. More... | |
Public Member Functions | |
WiredTigerSessionCache (WiredTigerKVEngine *engine) | |
WiredTigerSessionCache (WT_CONNECTION *conn) | |
~WiredTigerSessionCache () | |
std::unique_ptr< WiredTigerSession, WiredTigerSessionDeleter > | getSession () |
Returns a smart pointer to a previously released session for reuse, or creates a new session. More... | |
void | closeAll () |
Free all cached sessions and ensures that previously acquired sessions will be freed on release. More... | |
void | closeCursorsForQueuedDrops () |
Closes cached cursors for tables that are queued to be dropped. More... | |
void | closeAllCursors (const std::string &uri) |
Closes all cached cursors matching the uri. More... | |
void | shuttingDown () |
Transitions the cache to shutting down mode. More... | |
bool | isEphemeral () |
void | waitUntilDurable (bool forceCheckpoint, bool stableCheckpoint) |
Waits until all commits that happened before this call are durable, either by flushing the log or forcing a checkpoint if forceCheckpoint is true or the journal is disabled. More... | |
void | waitUntilPreparedUnitOfWorkCommitsOrAborts (OperationContext *opCtx) |
Waits until a prepared unit of work has ended (either been commited or aborted). More... | |
void | notifyPreparedUnitOfWorkHasCommittedOrAborted () |
Notifies waiters that the caller's perpared unit of work has ended (either committed or aborted). More... | |
WT_CONNECTION * | conn () const |
WiredTigerSnapshotManager & | snapshotManager () |
const WiredTigerSnapshotManager & | snapshotManager () const |
void | setJournalListener (JournalListener *jl) |
uint64_t | getCursorEpoch () const |
WiredTigerKVEngine * | getKVEngine () const |
Static Public Member Functions | |
static bool | isEngineCachingCursors () |
Indicates that WiredTiger should be configured to cache cursors. More... | |
Private Types | |
typedef std::vector< WiredTigerSession * > | SessionCache |
Private Member Functions | |
void | releaseSession (WiredTigerSession *session) |
Returns a session to the cache for later reuse. More... | |
Private Attributes | |
WiredTigerKVEngine * | _engine |
WT_CONNECTION * | _conn |
WiredTigerSnapshotManager | _snapshotManager |
AtomicUInt32 | _shuttingDown |
stdx::mutex | _cacheLock |
SessionCache | _sessions |
AtomicUInt64 | _epoch |
AtomicUInt64 | _cursorEpoch |
AtomicUInt32 | _lastSyncTime |
stdx::mutex | _lastSyncMutex |
stdx::mutex | _prepareCommittedOrAbortedMutex |
stdx::condition_variable | _prepareCommittedOrAbortedCond |
std::uint64_t | _lastCommitOrAbortCounter |
stdx::mutex | _journalListenerMutex |
JournalListener * | _journalListener = &NoOpJournalListener::instance |
WT_SESSION * | _waitUntilDurableSession = nullptr |
Static Private Attributes | |
static const uint32_t | kShuttingDownMask = 1 << 31 |
|
private |
mongo::WiredTigerSessionCache::WiredTigerSessionCache | ( | WiredTigerKVEngine * | engine | ) |
mongo::WiredTigerSessionCache::WiredTigerSessionCache | ( | WT_CONNECTION * | conn | ) |
mongo::WiredTigerSessionCache::~WiredTigerSessionCache | ( | ) |
void mongo::WiredTigerSessionCache::closeAll | ( | ) |
Free all cached sessions and ensures that previously acquired sessions will be freed on release.
void mongo::WiredTigerSessionCache::closeAllCursors | ( | const std::string & | uri | ) |
Closes all cached cursors matching the uri.
If the uri is empty, all cached cursors are closed.
void mongo::WiredTigerSessionCache::closeCursorsForQueuedDrops | ( | ) |
Closes cached cursors for tables that are queued to be dropped.
|
inline |
|
inline |
|
inline |
UniqueWiredTigerSession mongo::WiredTigerSessionCache::getSession | ( | ) |
Returns a smart pointer to a previously released session for reuse, or creates a new session.
This method must only be called while holding the global lock to avoid races with shuttingDown, but otherwise is thread safe.
|
static |
Indicates that WiredTiger should be configured to cache cursors.
bool mongo::WiredTigerSessionCache::isEphemeral | ( | ) |
void mongo::WiredTigerSessionCache::notifyPreparedUnitOfWorkHasCommittedOrAborted | ( | ) |
Notifies waiters that the caller's perpared unit of work has ended (either committed or aborted).
|
private |
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.
void mongo::WiredTigerSessionCache::setJournalListener | ( | JournalListener * | jl | ) |
void mongo::WiredTigerSessionCache::shuttingDown | ( | ) |
Transitions the cache to shutting down mode.
Any already released sessions are freed and any sessions released subsequently are leaked. Must be called while holding the global lock in exclusive mode to avoid races with getSession.
|
inline |
|
inline |
void mongo::WiredTigerSessionCache::waitUntilDurable | ( | bool | forceCheckpoint, |
bool | stableCheckpoint | ||
) |
Waits until all commits that happened before this call are durable, either by flushing the log or forcing a checkpoint if forceCheckpoint is true or the journal is disabled.
Uses a temporary session. Safe to call without any locks, even during shutdown.
void mongo::WiredTigerSessionCache::waitUntilPreparedUnitOfWorkCommitsOrAborts | ( | OperationContext * | opCtx | ) |
Waits until a prepared unit of work has ended (either been commited or aborted).
This should be used when encountering WT_PREPARE_CONFLICT errors. The caller is required to retry the conflicting WiredTiger API operation. A return from this function does not guarantee that the conflicting transaction has ended, only that one prepared unit of work in the process has signaled that it has ended. Accepts an OperationContext that will throw an AssertionException when interrupted.
This method is provided in WiredTigerSessionCache and not RecoveryUnit because all recovery units share the same session cache, and we want a recovery unit on one thread to signal all recovery units waiting for prepare conflicts across all other threads.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |