SERVER-111772 Audit invariants that assert preconditions/postconditions/arguments from src/mongo/db/query/client_cursor (#42913)

GitOrigin-RevId: ad0efd712f2e0d62097359d74af7624cd0fe8a01
This commit is contained in:
Catalin Sumanaru 2025-10-23 14:43:09 +01:00 committed by MongoDB Bot
parent 12dc078d3a
commit 903857a498
3 changed files with 6 additions and 6 deletions

View File

@ -388,7 +388,7 @@ ClientCursorPin CursorManager::registerCursor(OperationContext* opCtx,
// Make sure the PlanExecutor isn't registered, since we will register the ClientCursor wrapping // Make sure the PlanExecutor isn't registered, since we will register the ClientCursor wrapping
// it. // it.
invariant(cursorParams.exec); tassert(11177210, "cursorParams.exec must not be null", cursorParams.exec);
cursorParams.exec.get_deleter().dismissDisposal(); cursorParams.exec.get_deleter().dismissDisposal();
// Note we must hold the registration lock from now until insertion into '_cursorMap' to ensure // Note we must hold the registration lock from now until insertion into '_cursorMap' to ensure

View File

@ -84,8 +84,7 @@ void CursorResponseBuilder::done(CursorId cursorId,
const NamespaceString& cursorNamespace, const NamespaceString& cursorNamespace,
boost::optional<CursorMetrics> metrics, boost::optional<CursorMetrics> metrics,
const SerializationContext& serializationContext) { const SerializationContext& serializationContext) {
invariant(_active); tassert(11177212, "done() can only be called on an active CursorResponseBuilder", _active);
_batch.reset(); _batch.reset();
if (!_postBatchResumeToken.isEmpty()) { if (!_postBatchResumeToken.isEmpty()) {
_cursorObject->append(kPostBatchResumeTokenField, _postBatchResumeToken); _cursorObject->append(kPostBatchResumeTokenField, _postBatchResumeToken);

View File

@ -91,13 +91,14 @@ public:
} }
size_t bytesUsed() const { size_t bytesUsed() const {
invariant(_active); tassert(
11177213, "bytesUsed() can only be called on an active CursorResponseBuilder", _active);
return _batch->len(); return _batch->len();
} }
MONGO_COMPILER_ALWAYS_INLINE void append(const BSONObj& obj) { MONGO_COMPILER_ALWAYS_INLINE void append(const BSONObj& obj) {
invariant(_active); tassert(
11177214, "append() can only be called on an active CursorResponseBuilder", _active);
_batch->append(obj); _batch->append(obj);
_numDocs++; _numDocs++;
} }