0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-25 09:19:32 +01:00

SERVER-91203 AutoGetters should establish capped snapshots for secondary namespaces (#23157)

GitOrigin-RevId: 8426ffda43d081c4ee4b92a9fe3f43fa13fe77c7
This commit is contained in:
Allison Easton 2024-06-11 13:05:39 +02:00 committed by MongoDB Bot
parent 259f1c2412
commit a9b3e74fc6
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,22 @@
// Tests that lookups on local capped collections acquire a snapshot on the capped collection
// correctly. Tests the scenario fixed by SERVER-91203 no longer causes a crash.
let rst = new ReplSetTest({nodes: {n0: {profile: "0"}}});
rst.startSet();
rst.initiate();
const dbName = "test";
const collName = "foo";
let testDB = rst.getPrimary().getDB(dbName);
let testColl = testDB.getCollection(collName);
testColl.insert({a: 1});
testDB.setProfilingLevel(2);
const pipeline =
[{$lookup: {from: 'system.profile', localField: 'key', foreignField: 'key', as: 'results'}}];
testColl.aggregate(pipeline).toArray();
rst.stopSet();

View File

@ -601,6 +601,11 @@ ConsistentCatalogAndSnapshot getConsistentCatalogAndSnapshot(
// openCollection is eventually called to construct a Collection object from the durable
// catalog.
establishCappedSnapshotIfNeeded(opCtx, catalogBeforeSnapshot, nsOrUUID);
if (resolvedSecondaryNamespaces) {
for (const auto& secondaryNss : *resolvedSecondaryNamespaces) {
establishCappedSnapshotIfNeeded(opCtx, catalogBeforeSnapshot, {secondaryNss});
}
}
shard_role_details::getRecoveryUnit(opCtx)->preallocateSnapshot();