diff options
Diffstat (limited to 'src/mongo/db/session_catalog.h')
-rw-r--r-- | src/mongo/db/session_catalog.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/session_catalog.h b/src/mongo/db/session_catalog.h index b049550efd9..6201d6fd72b 100644 --- a/src/mongo/db/session_catalog.h +++ b/src/mongo/db/session_catalog.h @@ -60,6 +60,9 @@ class SessionCatalog { friend class OperationContextSession; public: + using OnEagerlyReapedSessionsFn = + unique_function<void(ServiceContext*, std::vector<LogicalSessionId>)>; + class ScopedCheckedOutSession; class SessionToKill; @@ -138,6 +141,15 @@ public: */ size_t size() const; + /** + * Registers a callback to run when sessions are "eagerly" reaped from the catalog, ie without + * waiting for a logical session cache refresh. + */ + void setOnEagerlyReapedSessionsFn(OnEagerlyReapedSessionsFn fn) { + invariant(!_onEagerlyReapedSessionsFn); + _onEagerlyReapedSessionsFn = std::move(fn); + } + private: /** * Tracks the runtime info for transaction sessions that corresponds to the same logical @@ -210,6 +222,11 @@ private: boost::optional<KillToken> killToken, boost::optional<TxnNumber> clientTxnNumberStarted); + // Called when sessions are reaped from memory "eagerly" ie directly by the SessionCatalog + // without waiting for a logical session cache refresh. Note this is set at process startup + // before multi-threading is enabled, so no synchronization is necessary. + boost::optional<OnEagerlyReapedSessionsFn> _onEagerlyReapedSessionsFn; + // Protects the state below mutable Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(4), "SessionCatalog::_mutex"); |