Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38349

Aggregate with exchange can trip invariant

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.7
    • Affects Version/s: 4.1.5
    • Component/s: Querying
    • None
    • Fully Compatible
    • ALL
    • 45

      (function() {
      
          const st = new ShardingTest({shards: 2});
      
          assert.commandWorked(st.s.adminCommand({enableSharding: 'test'}));
          st.ensurePrimaryShard("test", st.shard0.shardName);
      
          assert.commandWorked(st.s.adminCommand({shardCollection: 'test.user', key: {_id: 1}}));
      
          const mongosDB = st.s.getDB('test');
          const coll = mongosDB.user;
          coll.insert({_id: 1});
          coll.insert({_id: -1});
      
          var res = assert.commandWorked(mongosDB.runCommand({
              aggregate: coll.getName(),
              pipeline: [],
              exchange: {policy: 'broadcast', consumers: NumberInt(5), bufferSize: NumberInt(1024)},
              cursor: {batchSize: 0}
          }));
      
          st.stop();
      })();
      

      This test will trip this invariant.

      The situation is that we have an aggregation targeting 1 shard, but the request sent to the shard says there are 5 consumers, so the shard will open 5 cursors. On mongos, establishCursors() will return 5 cursors, leading to the invariant failing.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: