Tag: mongodb

  • MongoDB Exceeded memory limit for $group, but didn’t allow external sort

    When running MongoDB aggregation on big collection, we have this error:

    Exceeded memory limit for $group, but didn’t allow external sort

    Solution:

    Add option:

    { allowDiskUse: true }

     db.getCollection('orders').aggregate( [ { $sort : { created : 1} } ], { allowDiskUse: true } )

  • MongoError: Path collision at activity

    MongoDB 4.4 error:

    {
      message: 'Path collision at activity',
      stack: 'MongoError: Path collision at activity\n' +
        '    at Connection.<anonymous> (/project/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:443:61)\n' +
        '    at Connection.emit (events.js:315:20)\n' +
        '    at Connection.EventEmitter.emit (domain.js:483:12)\n' +
        '    at processMessage (/project/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:364:10)\n' +
        '    at Socket.<anonymous> (/project/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:533:15)\n' +
        '    at Socket.emit (events.js:315:20)\n' +
        '    at Socket.EventEmitter.emit (domain.js:483:12)\n' +
        '    at addChunk (_stream_readable.js:295:12)\n' +
        '    at readableAddChunk (_stream_readable.js:271:9)\n' +
        '    at Socket.Readable.push (_stream_readable.js:212:10)\n' +
        '    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)',
      operationTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1600849377 },
      ok: 0,
      errmsg: 'Path collision at activity',
      code: 31250,
      codeName: 'Location31250',
      '$clusterTime': {
        clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1600849377 },
        signature: {
          hash: Binary {
            _bsontype: 'Binary',
            sub_type: 0,
            position: 20,
            buffer: <Buffer d2 34 b7 ac bc a7 3f ea 38 d1 5c e3 26 58 39 43 d8 11 6c 83>
          },
          keyId: Long { _bsontype: 'Long', low_: 4, high_: 1596659428 }
        }
      },
      name: 'MongoError',
      level: 'info',
      timestamp: '2020-09-23 08:22:57',
      [Symbol(mongoErrorContextSymbol)]: {}
    }

    From version 4.4, MongoDB does not allow this projection of embedded document and a field of the same embedded document:

    db.inventory.find( {}, { size: 1, “size.uom”: 1 } )

    Solution:
    Update the query to have either:

    db.inventory.find( {}, { “size.uom”: 1 } )

    or

    db.inventory.find( {}, { size: 1,} )