From b9d2e18ca68246e5d21ed42a846ff4094867f159 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Mon, 6 Jul 2015 19:16:30 -0400 Subject: SERVER-17364 Don't stash RecoveryUnits across getMores We now tell PlanExecutors to detach from their OperationContexts and to shed all storage engine resources before stashing the ClientCursor. This is a heavier weight operation than a normal save/restoreState which is no longer allowed to change the OperationContext. --- src/mongo/db/clientcursor.h | 60 +++++++-------------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) (limited to 'src/mongo/db/clientcursor.h') diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 3f7e9797ae5..832d24e9a87 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -59,12 +59,15 @@ public: ClientCursor(CursorManager* cursorManager, PlanExecutor* exec, const std::string& ns, + bool isReadCommitted, int qopts = 0, const BSONObj query = BSONObj(), bool isAggCursor = false); /** * This ClientCursor is used to track sharding state for the given collection. + * + * Do not use outside of RangePreserver! */ explicit ClientCursor(const Collection* collection); @@ -81,6 +84,9 @@ public: CursorManager* cursorManager() const { return _cursorManager; } + bool isReadCommitted() const { + return _isReadCommitted; + } bool isAggCursor() const { return _isAggCursor; } @@ -180,49 +186,6 @@ public: static long long totalOpen(); - // - // Storage engine state for getMore. - // - - bool hasRecoveryUnit() const { - return _ownedRU.get() || _unownedRU; - } - - /** - * - * If a ClientCursor is created via DBDirectClient, it uses the same storage engine - * context as the DBDirectClient caller. We store this context in _unownedRU. We use - * this to verify that all further callers use the same RecoveryUnit. - * - * Once a ClientCursor has an unowned RecoveryUnit, it will always have one. - * - * Sets the unowned RecoveryUnit to 'ru'. Does NOT take ownership of the pointer. - */ - void setUnownedRecoveryUnit(RecoveryUnit* ru); - - /** - * Return the unowned RecoveryUnit. 'this' does not own pointer and therefore cannot - * transfer ownership. - */ - RecoveryUnit* getUnownedRecoveryUnit() const; - - /** - * If a ClientCursor is created via a client request, we bind its lifetime to the - * ClientCursor's by storing it un _ownedRU. In order to execute the query over repeated - * network requests, we have to keep the execution state around. - */ - - /** - * Set the owned recovery unit to 'ru'. Takes ownership of it. If there is a previous - * owned recovery unit, it is deleted. - */ - void setOwnedRecoveryUnit(RecoveryUnit* ru); - - /** - * Returns the owned recovery unit. Ownership is transferred to the caller. - */ - RecoveryUnit* releaseOwnedRecoveryUnit(); - private: friend class CursorManager; friend class ClientCursorPin; @@ -248,6 +211,8 @@ private: // The namespace we're operating on. std::string _ns; + const bool _isReadCommitted; + CursorManager* _cursorManager; // if we've added it to the total open counter yet @@ -270,7 +235,7 @@ private: // should not be killed or destroyed when the underlying collection is deleted. // // Note: This should *not* be set for the internal cursor used as input to an aggregation. - bool _isAggCursor; + const bool _isAggCursor; // Is this cursor in use? Defaults to false. bool _isPinned; @@ -288,13 +253,6 @@ private: // TODO: Document. uint64_t _leftoverMaxTimeMicros; - // Only one of these is not-NULL. - RecoveryUnit* _unownedRU; - std::unique_ptr _ownedRU; - // NOTE: _ownedRU must come before _exec, because _ownedRU must outlive _exec. - // The storage engine can have resources in the PlanExecutor that rely on - // the RecoveryUnit being alive. - // // The underlying execution machinery. // -- cgit v1.2.1