[SERVER-56368] Prohibit running $backupCursor/$backupCursorExtend on an aggregation against a collection Created: 26/Apr/21  Updated: 29/Oct/23  Resolved: 27/Apr/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.0-rc0, 4.4.18

Type: Bug Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-63050 using $backupCursor and referencing a... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v4.4
Steps To Reproduce:

(function() {
"use strict";
 
const numNodes = 1;
const rst = new ReplSetTest({
    nodes: numNodes,
    nodeOptions: {
        setParameter: {logComponentVerbosity: tojson({command: 2})},
    }
});
rst.startSet();
rst.initiateWithNodeZeroAsPrimary()
 
const dbName = "test";
const collName = "foo";
 
const db = rst.getPrimary().getDB(dbName);
 
assert.commandWorked(db.getCollection(collName).insert({}));
let cursor = db.getCollection(collName).aggregate([{$backupCursor: {}}]);  // crash.
cursor.close();
cursor = db.aggregate([{$backupCursor: {}}]);  // ok.
cursor.close();
 
rst.stopSet();
}());

Sprint: Execution Team 2021-05-03
Participants:
Linked BF Score: 133

 Description   

When running a $backupCursor aggregation against a collection, we execute this code path. This path locks the collection the aggregation was executed against and opens a storage transaction using the lock-free reads AutoGetCollection helper.

However, when running a collection-less $backupCursor aggregation, we execute this code path and we don't lock any collection. This is the documented way of opening a backup cursor.

 

Collection-less aggregation example:

db.aggregate([{$backupCursor: {}}]);

 

Aggregration against a collection example:

db.getCollection("...").aggregate([{$backupCursor: {}}]);



 Comments   
Comment by Githook User [ 30/Sep/22 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-56368 Prohibit running $backupCursor/$backupCursorExtend on an aggregation against a collection

(cherry picked from commit 8291c1deb9dd7476af8c631e55b7ff46bca6a426)
Branch: v4.4
https://github.com/10gen/mongo-enterprise-modules/commit/703761c912ea70367cfcd86f1ea726555dd8af23

Comment by Githook User [ 27/Apr/21 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-56368 Prohibit running $backupCursor/$backupCursorExtend on an aggregation against a collection
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/8291c1deb9dd7476af8c631e55b7ff46bca6a426

Generated at Thu Feb 08 05:39:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.