mirror of https://github.com/mongodb/mongo
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:
parent
12dc078d3a
commit
903857a498
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue