diff options
author | Ian Boros <ian.boros@10gen.com> | 2018-01-22 16:15:05 -0500 |
---|---|---|
committer | Ian Boros <ian.boros@10gen.com> | 2018-02-20 10:36:24 -0500 |
commit | 2558b58366d5807af06e7cd8e36142d338350600 (patch) | |
tree | 57320e1fe48c8a5551d5d6b8ac4919b41ee8f40c /src/mongo/s/query/cluster_cursor_manager.h | |
parent | 2ae87330910dd7af58507c77d0363d267be8381e (diff) | |
download | mongo-2558b58366d5807af06e7cd8e36142d338350600.tar.gz |
SERVER-32957 part 1: mongos will now destroy kill pending cursors on checkin
Diffstat (limited to 'src/mongo/s/query/cluster_cursor_manager.h')
-rw-r--r-- | src/mongo/s/query/cluster_cursor_manager.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/mongo/s/query/cluster_cursor_manager.h b/src/mongo/s/query/cluster_cursor_manager.h index 923e6914953..4f172cb9715 100644 --- a/src/mongo/s/query/cluster_cursor_manager.h +++ b/src/mongo/s/query/cluster_cursor_manager.h @@ -127,10 +127,11 @@ public: * A PinnedCursor can either be in a state where it owns a cursor, or can be in a null state * where it owns no cursor. If a cursor is owned, the underlying cursor can be iterated with * next(), and the underlying cursor can be returned to the manager with the returnCursor() - * method (and after it is returned, no cursor will be owned). + * method (and after it is returned, no cursor will be owned). When a PinnedCursor is created, + * the underlying cursor is attached to the current OperationContext. * - * Invoking the PinnedCursor's destructor while it owns a cursor will kill and return the - * cursor. + * Invoking the PinnedCursor's destructor while it owns a cursor will kill, detach from the + * current OperationContext, and return the cursor. */ class PinnedCursor { MONGO_DISALLOW_COPYING(PinnedCursor); @@ -167,17 +168,6 @@ public: StatusWith<ClusterQueryResult> next(RouterExecStage::ExecContext); /** - * Sets the operation context for the cursor. Must be called before the first call to - * next(). - */ - void reattachToOperationContext(OperationContext* opCtx); - - /** - * Detaches the cursor from its current OperationContext. - */ - void detachFromOperationContext(); - - /** * Returns whether or not the underlying cursor is tailing a capped collection. Cannot be * called after returnCursor() is called. A cursor must be owned. */ @@ -191,8 +181,9 @@ public: bool isTailableAndAwaitData() const; /** - * Transfers ownership of the underlying cursor back to the manager. A cursor must be - * owned, and a cursor will no longer be owned after this method completes. + * Transfers ownership of the underlying cursor back to the manager, and detaches it from + * the current OperationContext. A cursor must be owned, and a cursor will no longer be + * owned after this method completes. * * If 'Exhausted' is passed, the manager will de-register and destroy the cursor after it * is returned. @@ -310,6 +301,8 @@ public: * returns an error Status with code CursorInUse. If the given cursor is not registered or has * a pending kill, returns an error Status with code CursorNotFound. * + * Checking out a cursor will attach it to the given operation context. + * * 'authChecker' is function that will be called with the list of users authorized to use this * cursor. This function should check whether the current client is also authorized to use this * cursor, and if not, return an error status, which will cause checkOutCursor to fail. @@ -342,9 +335,12 @@ public: * If the given cursor is not registered, returns an error Status with code CursorNotFound. * Otherwise, marks the cursor as 'kill pending' and returns Status::OK(). * + * A thread which is currently using a cursor may not call killCursor() on it, but rather + * should kill the cursor by checking it back into the manager in the exhausted state. + * * Does not block. */ - Status killCursor(const NamespaceString& nss, CursorId cursorId); + Status killCursor(OperationContext* opCtx, const NamespaceString& nss, CursorId cursorId); /** * Informs the manager that all mortal cursors with a 'last active' time equal to or earlier @@ -445,6 +441,14 @@ private: CursorState cursorState); /** + * Will detach a cursor, release the lock and then call kill() on it. + */ + void detachAndKillCursor(stdx::unique_lock<stdx::mutex> lk, + OperationContext* opCtx, + const NamespaceString& nss, + CursorId cursorId); + + /** * Returns a pointer to the CursorEntry for the given cursor. If the given cursor is not * registered, returns null. * |