37 #include <wiredtiger.h> 41 #include "mongo/platform/atomic_word.h" 42 #include "mongo/stdx/mutex.h" 43 #include "mongo/util/concurrency/spin_lock.h" 47 class WiredTigerKVEngine;
48 class WiredTigerSessionCache;
74 WiredTigerSession(WT_CONNECTION* conn, uint64_t epoch = 0, uint64_t cursorEpoch = 0);
87 uint64_t cursorEpoch = 0);
95 WT_CURSOR*
getCursor(
const std::string&
uri, uint64_t
id,
bool forRecordStore);
180 std::unique_ptr<WiredTigerSession, WiredTigerSessionDeleter>
getSession();
stdx::condition_variable _prepareCommittedOrAbortedCond
Definition: wiredtiger_session_cache.h:282
static NoOpJournalListener instance
Definition: journal_listener.h:70
void waitUntilDurable(bool forceCheckpoint, bool stableCheckpoint)
Waits until all commits that happened before this call are durable, either by flushing the log or for...
Definition: wiredtiger_session_cache.cpp:217
WiredTigerSessionCache(WiredTigerKVEngine *engine)
Definition: wiredtiger_session_cache.cpp:187
WT_CONNECTION * conn() const
Definition: wiredtiger_session_cache.h:234
const uint64_t _epoch
Definition: wiredtiger_session_cache.h:142
WT_SESSION * _session
Definition: wiredtiger_session_cache.h:145
KVEngine * engine
Definition: kv_engine_test_timestamps.cpp:205
CursorCache _cursors
Definition: wiredtiger_session_cache.h:146
uint64_t getCursorEpoch() const
Definition: wiredtiger_session_cache.h:247
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
WT_CURSOR * _cursor
Definition: wiredtiger_session_cache.h:57
void notifyPreparedUnitOfWorkHasCommittedOrAborted()
Notifies waiters that the caller's perpared unit of work has ended (either committed or aborted).
Definition: wiredtiger_session_cache.cpp:301
int cursorsOut() const
Definition: wiredtiger_session_cache.h:107
std::list< WiredTigerCachedCursor > CursorCache
Definition: wiredtiger_session_cache.h:130
stdx::mutex _journalListenerMutex
Definition: wiredtiger_session_cache.h:286
AtomicUInt64 _epoch
Definition: wiredtiger_session_cache.h:271
static uint64_t genTableId()
Definition: wiredtiger_session_cache.cpp:181
static bool isEngineCachingCursors()
Indicates that WiredTiger should be configured to cache cursors.
Definition: wiredtiger_session_cache.cpp:437
WiredTigerCachedCursor(uint64_t id, uint64_t gen, WT_CURSOR *cursor)
Definition: wiredtiger_session_cache.h:52
WiredTigerSessionCache * _cache
Definition: wiredtiger_session_cache.h:144
JournalListener * _journalListener
Definition: wiredtiger_session_cache.h:288
This is a structure that caches 1 cursor for each uri.
Definition: wiredtiger_session_cache.h:65
uint64_t _cursorEpoch
Definition: wiredtiger_session_cache.h:143
void shuttingDown()
Transitions the cache to shutting down mode.
Definition: wiredtiger_session_cache.cpp:197
void setJournalListener(JournalListener *jl)
Definition: wiredtiger_session_cache.cpp:432
const WiredTigerSnapshotManager & snapshotManager() const
Definition: wiredtiger_session_cache.h:241
uint64_t _cursorGen
Definition: wiredtiger_session_cache.h:147
AtomicUInt64 _cursorEpoch
Definition: wiredtiger_session_cache.h:274
uint64_t _getEpoch() const
Definition: wiredtiger_session_cache.h:133
bool isDropQueuedIdentsAtSessionEndAllowed() const
Definition: wiredtiger_session_cache.h:111
AtomicUInt32 _shuttingDown
Definition: wiredtiger_session_cache.h:263
Definition: wiredtiger_kv_engine.h:66
~WiredTigerSessionCache()
Definition: wiredtiger_session_cache.cpp:193
std::unique_ptr< WiredTigerSession, WiredTigerSessionDeleter > getSession()
Returns a smart pointer to a previously released session for reuse, or creates a new session.
Definition: wiredtiger_session_cache.cpp:346
WiredTigerKVEngine * _engine
Definition: wiredtiger_session_cache.h:256
This class allows for the storageEngine to alert the rest of the system about journaled write progres...
Definition: journal_listener.h:48
Definition: wiredtiger_session_cache.h:50
stdx::mutex _cacheLock
Definition: wiredtiger_session_cache.h:266
WiredTigerKVEngine * getKVEngine() const
Definition: wiredtiger_session_cache.h:251
SessionCache _sessions
Definition: wiredtiger_session_cache.h:268
std::vector< WiredTigerSession * > SessionCache
Definition: wiredtiger_session_cache.h:267
WT_SESSION * _waitUntilDurableSession
Definition: wiredtiger_session_cache.h:290
void operator()(WiredTigerSession *session) const
Definition: wiredtiger_session_cache.cpp:441
stdx::mutex _prepareCommittedOrAbortedMutex
Definition: wiredtiger_session_cache.h:281
WT_CURSOR * getCursor(const std::string &uri, uint64_t id, bool forRecordStore)
Definition: wiredtiger_session_cache.cpp:108
WiredTigerSnapshotManager & snapshotManager()
Definition: wiredtiger_session_cache.h:238
WT_SESSION * getSession() const
Definition: wiredtiger_session_cache.h:91
void closeCursorsForQueuedDrops(WiredTigerKVEngine *engine)
Definition: wiredtiger_session_cache.cpp:163
void dropQueuedIdentsAtSessionEndAllowed(bool dropQueuedIdentsAtSessionEnd)
Definition: wiredtiger_session_cache.h:115
static const uint32_t kShuttingDownMask
Definition: wiredtiger_session_cache.h:264
void closeAllCursors(const std::string &uri)
Closes all cached cursors matching the uri.
Definition: wiredtiger_session_cache.cpp:149
void releaseCursor(uint64_t id, WT_CURSOR *cursor)
Definition: wiredtiger_session_cache.cpp:129
void closeAll()
Free all cached sessions and ensures that previously acquired sessions will be freed on release.
Definition: wiredtiger_session_cache.cpp:327
WiredTigerSession(WT_CONNECTION *conn, uint64_t epoch=0, uint64_t cursorEpoch=0)
Creates a new WT session on the specified connection.
Definition: wiredtiger_session_cache.cpp:84
stdx::mutex _lastSyncMutex
Definition: wiredtiger_session_cache.h:278
int _cursorsOut
Definition: wiredtiger_session_cache.h:148
uint64_t _id
Definition: wiredtiger_session_cache.h:55
bool isEphemeral()
Definition: wiredtiger_session_cache.cpp:342
std::uint64_t _lastCommitOrAbortCounter
Definition: wiredtiger_session_cache.h:283
void releaseSession(WiredTigerSession *session)
Returns a session to the cache for later reuse.
Definition: wiredtiger_session_cache.cpp:367
AtomicUInt32 _lastSyncTime
Definition: wiredtiger_session_cache.h:277
bool _dropQueuedIdentsAtSessionEnd
Definition: wiredtiger_session_cache.h:149
void closeCursorsForQueuedDrops()
Closes cached cursors for tables that are queued to be dropped.
Definition: wiredtiger_session_cache.cpp:317
This deleter automatically releases WiredTigerSession objects when no longer needed.
Definition: wiredtiger_session_cache.h:165
uint64_t _gen
Definition: wiredtiger_session_cache.h:56
This cache implements a shared pool of WiredTiger sessions with the goal to amortize the cost of sess...
Definition: wiredtiger_session_cache.h:156
static const uint64_t kMetadataTableId
For "metadata:" cursors.
Definition: wiredtiger_session_cache.h:124
void closeAllCursors(const std::string &uri)
Closes all cached cursors matching the uri.
Definition: wiredtiger_session_cache.cpp:310
WiredTigerSnapshotManager _snapshotManager
Definition: wiredtiger_session_cache.h:258
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
std::unique_ptr< WiredTigerSession, typename WiredTigerSessionCache::WiredTigerSessionDeleter > UniqueWiredTigerSession
A unique handle type for WiredTigerSession pointers obtained from a WiredTigerSessionCache.
Definition: wiredtiger_session_cache.h:305
uint64_t _getCursorEpoch() const
Definition: wiredtiger_session_cache.h:138
WT_CONNECTION * _conn
Definition: wiredtiger_session_cache.h:257
~WiredTigerSession()
Definition: wiredtiger_session_cache.cpp:102
Definition: wiredtiger_snapshot_manager.h:45
std::string uri
Definition: wiredtiger_standard_record_store_test.cpp:367
void waitUntilPreparedUnitOfWorkCommitsOrAborts(OperationContext *opCtx)
Waits until a prepared unit of work has ended (either been commited or aborted).
Definition: wiredtiger_session_cache.cpp:291