summaryrefslogtreecommitdiff
path: root/src/mongo/db/cursor_manager.h
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/cursor_manager.h
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/cursor_manager.h')
-rw-r--r--src/mongo/db/cursor_manager.h39
1 files changed, 11 insertions, 28 deletions
diff --git a/src/mongo/db/cursor_manager.h b/src/mongo/db/cursor_manager.h
index 3111898557d..9d0b5a710a8 100644
--- a/src/mongo/db/cursor_manager.h
+++ b/src/mongo/db/cursor_manager.h
@@ -142,7 +142,10 @@ public:
* operation next checks for interruption.
* Case (2) will only occur if the cursor is pinned.
*
- * Returns ErrorCodes::CursorNotFound if the cursor id is not owned by this manager.
+ * Returns ErrorCodes::CursorNotFound if the cursor id is not owned by this manager. Returns
+ * ErrorCodes::OperationFailed if attempting to erase a pinned cursor.
+ *
+ * If 'shouldAudit' is true, will perform audit logging.
*/
Status killCursor(OperationContext* opCtx, CursorId id);
@@ -191,17 +194,6 @@ public:
const SessionKiller::Matcher& matcher);
/**
- * Returns a vector of open cursor ids registered on the `nss`. The result doesn't include
- * cursors registered for a different namespace but also acting on `nss` (e.g. in presence of
- * sub-pipelines).
- *
- * Locks/inspects one partition at a time, hence the result might not include new cursors being
- * opened on the namespace. The only guarantee is that the result will include any cursor opened
- * before calling this method and not closed before iterating the partition holding it.
- */
- std::vector<CursorId> getCursorIdsForNamespace(const NamespaceString& nss);
-
- /**
* Set the CursorManager's ClockSource*.
*/
void setPreciseClockSource(ClockSource* preciseClockSource) {
@@ -212,17 +204,14 @@ private:
static constexpr int kNumPartitions = 16;
friend class ClientCursorPin;
- // deregisterAndDestroyCursor deregisters the cursor from the manager's cursorMap, then safely
- // destroys the cursor. The first overload requires having acquired the cursor manager partition
- // lock already.
+ ClientCursorPin _registerCursor(
+ OperationContext* opCtx, std::unique_ptr<ClientCursor, ClientCursor::Deleter> clientCursor);
+
+ void deregisterCursor(ClientCursor* cursor);
void deregisterAndDestroyCursor(
- Partitioned<stdx::unordered_map<CursorId, ClientCursor*>>::OnePartition&& lk,
+ Partitioned<stdx::unordered_map<CursorId, ClientCursor*>>::OnePartition&&,
OperationContext* opCtx,
std::unique_ptr<ClientCursor, ClientCursor::Deleter> cursor);
- void deregisterAndDestroyCursor(OperationContext* opCtx,
- std::unique_ptr<ClientCursor, ClientCursor::Deleter> cursor);
- void _destroyCursor(OperationContext* opCtx,
- std::unique_ptr<ClientCursor, ClientCursor::Deleter> cursor);
void unpin(OperationContext* opCtx,
std::unique_ptr<ClientCursor, ClientCursor::Deleter> cursor);
@@ -235,13 +224,7 @@ private:
// 'cursor'.
if (auto opKey = cursor->getOperationKey()) {
stdx::lock_guard<Latch> lk(_opKeyMutex);
- auto it = _opKeyMap.find(*opKey);
- if (it != _opKeyMap.end()) {
- it->second.erase(cursor->cursorid());
- if (it->second.empty()) {
- _opKeyMap.erase(*opKey);
- }
- }
+ _opKeyMap.erase(*opKey);
}
map->erase(cursor->cursorid());
}
@@ -269,7 +252,7 @@ private:
// cursors in the map above are not present in this map, since OperationKey is not required when
// registering a cursor.
mutable Mutex _opKeyMutex = MONGO_MAKE_LATCH("CursorManager::_opKeyMutex");
- stdx::unordered_map<OperationKey, std::set<CursorId>, UUID::Hash> _opKeyMap;
+ stdx::unordered_map<OperationKey, CursorId, UUID::Hash> _opKeyMap;
ClockSource* _preciseClockSource;
};