SERVER-126785: Replace AutoGetCollection in tests with collection acquisitions (#53819)

GitOrigin-RevId: c32991eed9a65460feccf96acb593f7730890d24
This commit is contained in:
Thomas Goyne 2026-05-20 13:52:35 -07:00 committed by MongoDB Bot
parent cfd73e121b
commit 131bdc5270
7 changed files with 156 additions and 75 deletions

View File

@ -34,9 +34,9 @@
#include "mongo/db/replicated_fast_count/replicated_fast_count_init.h"
#include "mongo/db/replicated_fast_count/replicated_fast_count_manager.h"
#include "mongo/db/replicated_fast_count/replicated_fast_count_test_helpers.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/catalog_test_fixture.h"
#include "mongo/db/shard_role/shard_catalog/create_collection.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/db/storage/write_unit_of_work.h"
#include "mongo/unittest/unittest.h"
@ -82,13 +82,16 @@ TEST_F(PersistedSizeCountTest, UuidExistsInSizeCountStore) {
constexpr int expectedCount = 5;
int expectedSize = 0;
AutoGetCollection coll(operationContext(), nss, LockMode::MODE_IX);
auto coll = acquireCollection(operationContext(),
CollectionAcquisitionRequest::fromOpCtx(
operationContext(), nss, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
{
WriteUnitOfWork wuow(operationContext(),
WriteUnitOfWork::kGroupForPossiblyRetryableOperations);
for (int i = 0; i < expectedCount; ++i) {
const BSONObj document = BSON("_id" << i << "x" << i);
ASSERT_OK(Helpers::insert(operationContext(), *coll, document));
ASSERT_OK(Helpers::insert(operationContext(), coll.getCollectionPtr(), document));
expectedSize += document.objsize();
}
wuow.commit();
@ -96,7 +99,8 @@ TEST_F(PersistedSizeCountTest, UuidExistsInSizeCountStore) {
manager->flushSync(operationContext());
const CollectionSizeCount sizeCount = coll->persistedSizeCount(operationContext());
const CollectionSizeCount sizeCount =
coll.getCollectionPtr()->persistedSizeCount(operationContext());
EXPECT_EQ(sizeCount.count, expectedCount);
EXPECT_EQ(sizeCount.size, expectedSize);
}

View File

@ -33,7 +33,6 @@
#include "mongo/db/replicated_fast_count/replicated_fast_count_test_helpers.h"
#include "mongo/db/replicated_fast_count/size_count_store.h"
#include "mongo/db/replicated_fast_count/size_count_timestamp_store.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/catalog_test_fixture.h"
#include "mongo/db/shard_role/shard_catalog/clustered_collection_util.h"
#include "mongo/db/shard_role/transaction_resources.h"

View File

@ -45,6 +45,7 @@
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/catalog_test_fixture.h"
#include "mongo/db/shard_role/shard_catalog/create_collection.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/db/shard_role/transaction_resources.h"
#include "mongo/db/storage/recovery_unit.h"
#include "mongo/db/storage/write_unit_of_work.h"
@ -448,10 +449,16 @@ protected:
ASSERT_OK(createCollection(_opCtx, _nss1.dbName(), BSON("create" << _nss1.coll())));
ASSERT_OK(createCollection(_opCtx, _nss2.dbName(), BSON("create" << _nss2.coll())));
{
AutoGetCollection coll1(_opCtx, _nss1, LockMode::MODE_IS);
AutoGetCollection coll2(_opCtx, _nss2, LockMode::MODE_IS);
_uuid1 = coll1->uuid();
_uuid2 = coll2->uuid();
auto coll1 = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, _nss1, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
auto coll2 = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, _nss2, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
_uuid1 = coll1.uuid();
_uuid2 = coll2.uuid();
}
}

View File

@ -32,8 +32,8 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/replicated_fast_count/replicated_fast_count_manager.h"
#include "mongo/db/rss/replicated_storage_service.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/catalog_test_fixture.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/db/shard_role/transaction_resources.h"
#include "mongo/db/storage/ident.h"
#include "mongo/db/storage/kv/kv_engine.h"
@ -75,12 +75,19 @@ const NamespaceString replicatedFastCountStoreTimestampsNss =
TEST_F(ReplicatedFastCountInitTest,
setUpReplicatedFastCountCreatesInternalCollectionsAndStartsUpThread) {
{
AutoGetCollection coll(_opCtx, replicatedFastCountStoreNss, LockMode::MODE_IS);
ASSERT(!coll);
auto coll = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, replicatedFastCountStoreNss, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
ASSERT(!coll.exists());
AutoGetCollection collTimestamps(
_opCtx, replicatedFastCountStoreTimestampsNss, LockMode::MODE_IS);
ASSERT(!collTimestamps);
auto collTimestamps = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, replicatedFastCountStoreTimestampsNss, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
ASSERT(!collTimestamps.exists());
}
EXPECT_EQ(_fastCountManager->isRunning_ForTest(), false);
@ -88,12 +95,19 @@ TEST_F(ReplicatedFastCountInitTest,
setUpReplicatedFastCount(_opCtx);
{
AutoGetCollection coll(_opCtx, replicatedFastCountStoreNss, LockMode::MODE_IS);
ASSERT(coll);
auto coll = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, replicatedFastCountStoreNss, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
ASSERT(coll.exists());
AutoGetCollection collTimestamps(
_opCtx, replicatedFastCountStoreTimestampsNss, LockMode::MODE_IS);
ASSERT(collTimestamps);
auto collTimestamps = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, replicatedFastCountStoreTimestampsNss, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
ASSERT(collTimestamps.exists());
}
EXPECT_EQ(_fastCountManager->isRunning_ForTest(), true);

View File

@ -39,9 +39,9 @@
#include "mongo/db/replicated_fast_count/replicated_fast_count_init.h"
#include "mongo/db/replicated_fast_count/replicated_fast_count_manager.h"
#include "mongo/db/replicated_fast_count/replicated_fast_count_test_helpers.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/catalog_test_fixture.h"
#include "mongo/db/shard_role/shard_catalog/create_collection.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/db/shard_role/transaction_resources.h"
#include "mongo/db/storage/recovery_unit.h"
#include "mongo/db/storage/write_unit_of_work.h"
@ -79,12 +79,21 @@ protected:
ASSERT_OK(createCollection(_opCtx, _nss2.dbName(), BSON("create" << _nss2.coll())));
ASSERT_OK(createCollection(_opCtx, _nss3.dbName(), BSON("create" << _nss3.coll())));
{
AutoGetCollection coll1(_opCtx, _nss1, LockMode::MODE_IS);
AutoGetCollection coll2(_opCtx, _nss2, LockMode::MODE_IS);
AutoGetCollection coll3(_opCtx, _nss3, LockMode::MODE_IS);
_uuid1 = coll1->uuid();
_uuid2 = coll2->uuid();
_uuid3 = coll3->uuid();
auto coll1 = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, _nss1, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
auto coll2 = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, _nss2, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
auto coll3 = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, _nss3, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
_uuid1 = coll1.uuid();
_uuid2 = coll2.uuid();
_uuid3 = coll3.uuid();
}
}
@ -791,7 +800,10 @@ TEST_P(ReplicatedFastCountCappedCollectionTest, CorrectSizeCountAfterCapReached)
<< maxDocs * sampleDocForInsert.objsize())));
}
AutoGetCollection cappedColl(_opCtx, nssCapped, LockMode::MODE_IX);
auto cappedColl = acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, nssCapped, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
for (int i = 0; i < maxDocs + 5; ++i) {
// Using the query-level InsertCommandRequest path here lets us avoid handling capped
@ -803,13 +815,15 @@ TEST_P(ReplicatedFastCountCappedCollectionTest, CorrectSizeCountAfterCapReached)
ASSERT_OK(result.results[0].getStatus());
if (i < maxDocs - 1) {
const auto [actualSize, actualCount] = cappedColl->latestSizeCount(_opCtx);
const auto [actualSize, actualCount] =
cappedColl.getCollectionPtr()->latestSizeCount(_opCtx);
const long long expectedCount = i + 1;
EXPECT_EQ(actualSize, expectedCount * sampleDocForInsert.objsize());
EXPECT_EQ(actualCount, expectedCount);
} else {
// After the collection cap has been reached, the size and count should stay the same.
const auto [actualSize, actualCount] = cappedColl->latestSizeCount(_opCtx);
const auto [actualSize, actualCount] =
cappedColl.getCollectionPtr()->latestSizeCount(_opCtx);
EXPECT_EQ(actualSize, maxDocs * sampleDocForInsert.objsize());
EXPECT_EQ(actualCount, maxDocs);
}
@ -825,15 +839,19 @@ TEST_F(ReplicatedFastCountTest, ReplicatedFastCountDoesNotTrackLocalCollections)
NamespaceString::createNamespaceString_forTest("local.coll");
ASSERT_OK(createCollection(_opCtx, internalNss.dbName(), BSON("create" << internalNss.coll())));
AutoGetCollection internalColl(_opCtx, internalNss, LockMode::MODE_IX);
const UUID internalUuid = internalColl->uuid();
auto internalColl =
acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, internalNss, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
const UUID internalUuid = internalColl.uuid();
const long long docsToInsertCount = 10;
long long expectedSize = 0;
WriteUnitOfWork wuow(_opCtx, WriteUnitOfWork::kGroupForPossiblyRetryableOperations);
for (size_t i = 0; i < docsToInsertCount; ++i) {
const BSONObj document = docGeneratorForInsert(i);
ASSERT_OK(Helpers::insert(_opCtx, *internalColl, document));
ASSERT_OK(Helpers::insert(_opCtx, internalColl.getCollectionPtr(), document));
expectedSize += document.objsize();
}
@ -851,8 +869,8 @@ TEST_F(ReplicatedFastCountTest, ReplicatedFastCountDoesNotTrackLocalCollections)
_opCtx, internalUuid, 0, 0);
// Size and count data for `internalColl` are still tracked through the record store.
EXPECT_EQ(internalColl->numRecords(_opCtx), docsToInsertCount);
EXPECT_EQ(internalColl->dataSize(_opCtx), expectedSize);
EXPECT_EQ(internalColl.getCollectionPtr()->numRecords(_opCtx), docsToInsertCount);
EXPECT_EQ(internalColl.getCollectionPtr()->dataSize(_opCtx), expectedSize);
}
TEST_F(ReplicatedFastCountTest, ReplicatedFastCountTracksNonLocalInternalCollections) {
@ -862,15 +880,19 @@ TEST_F(ReplicatedFastCountTest, ReplicatedFastCountTracksNonLocalInternalCollect
ASSERT_OK(
createCollection(_opCtx, internalNss.dbName(), BSON("create" << internalNss.coll())));
AutoGetCollection internalColl(_opCtx, internalNss, LockMode::MODE_IX);
const UUID internalUuid = internalColl->uuid();
auto internalColl =
acquireCollection(_opCtx,
CollectionAcquisitionRequest::fromOpCtx(
_opCtx, internalNss, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
const UUID internalUuid = internalColl.uuid();
const long long docsToInsertCount = 10;
long long expectedSize = 0;
WriteUnitOfWork wuow(_opCtx, WriteUnitOfWork::kGroupForPossiblyRetryableOperations);
for (size_t i = 0; i < docsToInsertCount; ++i) {
const BSONObj document = docGeneratorForInsert(i);
ASSERT_OK(Helpers::insert(_opCtx, *internalColl, document));
ASSERT_OK(Helpers::insert(_opCtx, internalColl.getCollectionPtr(), document));
expectedSize += document.objsize();
}
@ -897,14 +919,17 @@ class SizeMetadataLoggingTest : public ReplicatedFastCountTest {};
TEST_F(SizeMetadataLoggingTest, BasicInsertOplogEntry) {
RAIIServerParameterControllerForTest featureFlag("featureFlagReplicatedFastCount", true);
AutoGetCollection coll(_opCtx, _nss1, LockMode::MODE_IX);
auto coll = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(_opCtx, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
const auto docToInsert = docGeneratorForInsert(0);
const auto expectedSizeDelta = docToInsert.objsize();
{
WriteUnitOfWork wuow{_opCtx};
ASSERT_OK(Helpers::insert(_opCtx, *coll, docToInsert));
ASSERT_OK(Helpers::insert(_opCtx, coll.getCollectionPtr(), docToInsert));
wuow.commit();
}

View File

@ -45,6 +45,7 @@
#include "mongo/db/replicated_fast_count/size_count_store.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/create_collection.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/unittest/unittest.h"
namespace mongo::replicated_fast_count_test_helpers {
@ -55,13 +56,17 @@ void checkFastCountMetadataInInternalCollection(OperationContext* opCtx,
int64_t expectedCount,
int64_t expectedSize) {
{
AutoGetCollection fastCountColl(
auto fastCountColl = acquireCollection(
opCtx,
NamespaceString::makeGlobalConfigCollection(NamespaceString::kReplicatedFastCountStore),
LockMode::MODE_IS);
CollectionAcquisitionRequest::fromOpCtx(opCtx,
NamespaceString::makeGlobalConfigCollection(
NamespaceString::kReplicatedFastCountStore),
AcquisitionPrerequisites::kRead),
MODE_IS);
BSONObj persisted;
bool found = Helpers::findById(opCtx, fastCountColl->ns(), BSON("_id" << uuid), persisted);
bool found = Helpers::findById(
opCtx, fastCountColl.getCollectionPtr()->ns(), BSON("_id" << uuid), persisted);
EXPECT_EQ(found, expectPersisted);
if (!expectPersisted) {
@ -114,32 +119,35 @@ void insertDocs(OperationContext* opCtx,
const BSONObj& sampleDoc,
bool abortWithoutCommit) {
AutoGetCollection coll(opCtx, nss, LockMode::MODE_IX);
auto coll = acquireCollection(
opCtx,
CollectionAcquisitionRequest::fromOpCtx(opCtx, nss, AcquisitionPrerequisites::kWrite),
MODE_IX);
{
WriteUnitOfWork wuow{opCtx, WriteUnitOfWork::kGroupForPossiblyRetryableOperations};
for (int i = startingCount; i < startingCount + numDocs; ++i) {
BSONObj doc = makeDoc(i);
ASSERT_OK(Helpers::insert(opCtx, *coll, doc));
ASSERT_OK(Helpers::insert(opCtx, coll.getCollectionPtr(), doc));
}
checkUncommittedFastCountChanges(
opCtx, coll->uuid(), numDocs, numDocs * sampleDoc.objsize());
checkCommittedFastCountChanges(coll->uuid(), fastCountManager, startingCount, startingSize);
opCtx, coll.uuid(), numDocs, numDocs * sampleDoc.objsize());
checkCommittedFastCountChanges(coll.uuid(), fastCountManager, startingCount, startingSize);
if (!abortWithoutCommit) {
wuow.commit();
}
}
if (abortWithoutCommit) {
checkCommittedFastCountChanges(coll->uuid(), fastCountManager, startingCount, startingSize);
checkCommittedFastCountChanges(coll.uuid(), fastCountManager, startingCount, startingSize);
} else {
checkCommittedFastCountChanges(coll->uuid(),
checkCommittedFastCountChanges(coll.uuid(),
fastCountManager,
startingCount + numDocs,
startingSize + numDocs * sampleDoc.objsize());
}
checkUncommittedFastCountChanges(opCtx, coll->uuid(), 0, 0);
checkUncommittedFastCountChanges(opCtx, coll.uuid(), 0, 0);
}
void updateDocs(OperationContext* opCtx,

View File

@ -44,8 +44,8 @@
#include "mongo/db/replicated_fast_count/replicated_fast_count_test_helpers.h"
#include "mongo/db/session/session_catalog_mongod.h"
#include "mongo/db/session/session_txn_record_gen.h"
#include "mongo/db/shard_role/shard_catalog/catalog_raii.h"
#include "mongo/db/shard_role/shard_catalog/create_collection.h"
#include "mongo/db/shard_role/shard_role.h"
#include "mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h"
#include "mongo/db/transaction/transaction_participant.h"
#include "mongo/idl/idl_parser.h"
@ -97,10 +97,16 @@ protected:
ASSERT_OK(createCollection(_opCtx, _nss1.dbName(), BSON("create" << _nss1.coll())));
ASSERT_OK(createCollection(_opCtx, _nss2.dbName(), BSON("create" << _nss2.coll())));
AutoGetCollection coll1(_opCtx, _nss1, LockMode::MODE_IS);
AutoGetCollection coll2(_opCtx, _nss2, LockMode::MODE_IS);
_uuid1 = coll1->uuid();
_uuid2 = coll2->uuid();
auto coll1 = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(_opCtx, _nss1, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
auto coll2 = acquireCollection(
_opCtx,
CollectionAcquisitionRequest::fromOpCtx(_opCtx, _nss2, AcquisitionPrerequisites::kRead),
LockMode::MODE_IS);
_uuid1 = coll1.uuid();
_uuid2 = coll2.uuid();
}
void tearDown() override {
@ -232,12 +238,15 @@ TEST_F(ReplicatedFastCountTxnTest,
// Start the transaction and perform the insert on a fresh OperationContext.
beginTxn(sessionId, txnNumber, [&](OperationContext* opCtx1) {
AutoGetCollection coll(opCtx1, _nss1, LockMode::MODE_IX);
uuid = coll->uuid();
auto coll = acquireCollection(opCtx1,
CollectionAcquisitionRequest::fromOpCtx(
opCtx1, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
uuid = coll.uuid();
{
WriteUnitOfWork wuow{opCtx1};
ASSERT_OK(Helpers::insert(opCtx1, *coll, doc1));
ASSERT_OK(Helpers::insert(opCtx1, coll.getCollectionPtr(), doc1));
wuow.commit();
}
@ -257,12 +266,15 @@ TEST_F(ReplicatedFastCountTxnTest,
// Continue and commit the transaction.
continueAndCommitTxn(sessionId, txnNumber, [&](OperationContext* opCtx2) {
AutoGetCollection coll(opCtx2, _nss1, LockMode::MODE_IX);
EXPECT_EQ(coll->uuid(), *uuid);
auto coll = acquireCollection(opCtx2,
CollectionAcquisitionRequest::fromOpCtx(
opCtx2, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
ASSERT_EQ(coll.uuid(), *uuid);
{
WriteUnitOfWork wuow{opCtx2};
ASSERT_OK(Helpers::insert(opCtx2, *coll, doc2));
ASSERT_OK(Helpers::insert(opCtx2, coll.getCollectionPtr(), doc2));
wuow.commit();
}
@ -290,12 +302,15 @@ TEST_F(ReplicatedFastCountTxnTest, UncommittedChangesDiscardedAfterMultiDocument
// Start the transaction and perform the insert on a fresh OperationContext.
beginTxn(sessionId, txnNumber, [&](OperationContext* opCtx1) {
AutoGetCollection coll(opCtx1, _nss1, LockMode::MODE_IX);
uuid = coll->uuid();
auto coll = acquireCollection(opCtx1,
CollectionAcquisitionRequest::fromOpCtx(
opCtx1, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
uuid = coll.uuid();
{
WriteUnitOfWork wuow{opCtx1};
ASSERT_OK(Helpers::insert(opCtx1, *coll, doc1));
ASSERT_OK(Helpers::insert(opCtx1, coll.getCollectionPtr(), doc1));
wuow.commit();
}
@ -333,12 +348,15 @@ TEST_F(ReplicatedFastCountTxnTest, FastCountResetForSessionBetweenTransactions)
TxnNumber txnNumber(0);
beginTxn(_opCtx, sessionId, txnNumber, [&](OperationContext* opCtx) {
AutoGetCollection coll(opCtx, _nss1, LockMode::MODE_IX);
uuid = coll->uuid();
auto coll = acquireCollection(
opCtx,
CollectionAcquisitionRequest::fromOpCtx(opCtx, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
uuid = coll.uuid();
{
WriteUnitOfWork wuow{opCtx};
ASSERT_OK(Helpers::insert(opCtx, *coll, doc1));
ASSERT_OK(Helpers::insert(opCtx, coll.getCollectionPtr(), doc1));
wuow.commit();
}
@ -367,13 +385,16 @@ TEST_F(ReplicatedFastCountTxnTest, ApplyOpsOplogEntryContainsSizeDeltaMetadataSi
TxnNumber txnNumber(0);
UUID uuid = UUID::gen();
beginTxn(sessionId, txnNumber, [&](OperationContext* opCtx1) {
AutoGetCollection coll(opCtx1, _nss1, LockMode::MODE_IX);
auto coll = acquireCollection(opCtx1,
CollectionAcquisitionRequest::fromOpCtx(
opCtx1, _nss1, AcquisitionPrerequisites::kWrite),
LockMode::MODE_IX);
{
WriteUnitOfWork wuow{opCtx1};
ASSERT_OK(Helpers::insert(opCtx1, *coll, doc));
ASSERT_OK(Helpers::insert(opCtx1, coll.getCollectionPtr(), doc));
wuow.commit();
}
uuid = coll->uuid();
uuid = coll.uuid();
});
continueAndCommitTxn(sessionId, txnNumber, [&](OperationContext*) {});
@ -414,7 +435,7 @@ TEST_F(ReplicatedFastCountTxnTest, ApplyOpsOplogEntryContainsSizeDeltaMetadata)
CollectionAcquisitionRequest::fromOpCtx(
opCtx1, _nss1, AcquisitionPrerequisites::kWrite),
MODE_IX);
const auto uuid = coll.getCollectionPtr()->uuid();
const auto uuid = coll.uuid();
{
WriteUnitOfWork wuow{opCtx1};
ASSERT_OK(Helpers::insert(opCtx1, coll.getCollectionPtr(), doc));
@ -446,7 +467,7 @@ TEST_F(ReplicatedFastCountTxnTest, ApplyOpsOplogEntryContainsSizeDeltaMetadata)
CollectionAcquisitionRequest::fromOpCtx(
opCtx1, _nss2, AcquisitionPrerequisites::kWrite),
MODE_IX);
const auto uuid = coll.getCollectionPtr()->uuid();
const auto uuid = coll.uuid();
{
WriteUnitOfWork wuow{opCtx1};
ASSERT_OK(Helpers::insert(opCtx1, coll.getCollectionPtr(), doc));
@ -538,11 +559,14 @@ protected:
void addTransactionInsertOps(OperationContext* opCtx,
const NamespaceString& nss,
const std::vector<BSONObj>& docs) {
AutoGetCollection coll(opCtx, nss, MODE_IX);
auto coll = acquireCollection(
opCtx,
CollectionAcquisitionRequest::fromOpCtx(opCtx, nss, AcquisitionPrerequisites::kWrite),
MODE_IX);
auto txnParticipant = TransactionParticipant::get(opCtx);
for (const auto& doc : docs) {
auto operation = repl::DurableOplogEntry::makeInsertOperation(
nss, coll->uuid(), doc, doc["_id"].wrap());
nss, coll.uuid(), doc, doc["_id"].wrap());
operation.setSizeMetadata(repl::OplogEntrySizeMetadata{
SingleOpSizeMetadata(static_cast<int32_t>(doc.objsize()))});
txnParticipant.addTransactionOperation(opCtx, operation);