[SERVER-37077] Exchange boundaries are not validated, can result in invariant() failure Created: 11/Sep/18  Updated: 29/Oct/23  Resolved: 26/Sep/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 4.1.2
Fix Version/s: 4.1.4

Type: Bug Priority: Critical - P2
Reporter: David Storch Assignee: Martin Neupauer
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-37076 Aggregation exchange partitioning doe... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

(function() {
    "use strict";
 
    db.c.drop();
    assert.commandWorked(db.c.insert({a: 99}));
 
    let result = assert.commandWorked(db.runCommand({
        aggregate: "c",
        pipeline: [],
        exchange: {
            policy: "range",
            consumers: NumberInt(2),
            bufferSize: NumberInt(1024),
            key: {a: 1},
            // The last boundary value is not MaxKey, meaning that there could be input
            // data which we cannot place within a partition.
            boundaries: [{a: MinKey}, {a: 0}, {a: 50}],
            consumerids: [NumberInt(0), NumberInt(1)]
        },
        cursor: {batchSize: 0}
    }));
    assert.eq(result.cursors.length, 2);
    assert.eq(result.cursors[0].ok, true);
    assert.eq(result.cursors[1].ok, true);
    let firstCursorId = result.cursors[0].cursor.id;
    let secondCursorId = result.cursors[1].cursor.id;
 
    let firstGetMore =
        assert.commandWorked(db.runCommand({getMore: firstCursorId, collection: "c"}));
    printjson(firstGetMore);
 
    let secondGetMore =
        assert.commandWorked(db.runCommand({getMore: secondCursorId, collection: "c"}));
    printjson(secondGetMore);
}());

Sprint: Query 2018-09-24, Query 2018-10-08
Participants:

 Description   

The ExchangeSpec accepts an array of boundary values which 1) must be correctly sorted and 2) must begin with MinKey and end with MaxKey. It appears that these constraints are not validated when the exchange option to the aggregate command is parsed. This can result in an invariant() failure downstream (the same invariant failure reported in SERVER-37076). Instead, we should fail the aggregate command with an appropriate user assertion when the exchange boundaries are invalid.



 Comments   
Comment by Githook User [ 26/Sep/18 ]

Author:

{'name': 'Martin Neupauer', 'email': 'martin.neupauer@mongodb.com', 'username': 'MartinNeupauer'}

Message: SERVER-37077 Exchange boundaries are not validated, can result in invariant() failure
Branch: master
https://github.com/mongodb/mongo/commit/aa952ac3b0d54d651f1cd8f618baee4fe0e10efa

Generated at Thu Feb 08 04:44:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.