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

Segmentation fault when performing aggregation with $lookup.let and $lookup.pipeline

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.6
    • Component/s: Aggregation Framework
    • Labels:
      None
    • ALL

      Hello

      I encounter a segmentation fault problem with MongoDB 4.0.6 when executing one particular aggregation.

      MongoDB instance is deployed in Docker 18.09.1, running on Ubuntu 18.04.1, running on EC2 t3.xlarge instance. I was unable to reproduce the error in any other environment, however, it's often reproducible within these specifications.

      I've nailed the issue to this set of example data and aggregation query:

      db.actions

      { "_id" : ObjectId("5c5994639df716001e51e2c5"), "company_id" : 1, "campaign_id" : ObjectId("5c5994639df716001e51e2c4"), "brand" : "Test", "created_at" : ISODate("
      2019-02-05T13:49:23.670Z") } 
      { "_id" : ObjectId("5c59974b6c62000010a95700"), "company_id" : 1, "campaign_id" : ObjectId("5c59974b6c62000010a956ff"), "brand" : "Test", "created_at" : ISODate("
      2019-02-05T14:01:47.274Z") }

      db.campaigns

      { "_id" : ObjectId("5c5994639df716001e51e2c4"), "name" : "FR_WK1_test", "company_id" : 1, "created_at"
       : ISODate("2019-02-05T13:49:23.665Z") } 
      { "_id" : ObjectId("5c59974b6c62000010a956ff"), "name" : "FR_WK2_test2", "company_id" : 1, "created_at
      " : ISODate("2019-02-05T14:01:47.268Z") }

      The query

      db.actions.aggregate([
        { '$match': { 'company_id': 1 } },
        { '$group': {
          '_id': '$campaign_id',
          'brands': { '$addToSet': '$brand' },
        }},
        { '$lookup': {
          from: 'campaigns',
          localField: '_id',
          foreignField: '_id',
          as: 'campaign',
        }},
        { '$unwind': '$campaign' },
        { '$lookup': {
          from: 'data',
          let: { 'action_campaign_id': '$_id' },
          pipeline: [
            { '$match': {
              '$expr': {
                '$eq': ['$campaign_id', '$$action_campaign_id'],
              },
            }},
            { '$group': {
              '_id': '$campaign_id',
              'clicks': { '$sum': '$data.clicks' },
            }},
          ],
          as: 'kpi',
        }}
      ])

      db.data collection exists, but is empty. Adding some records to it didn't affect the outcome.

      The query above results either in this error:

      2019-02-06T12:50:16.859+0000 E QUERY    [js] Error: command failed: { 
              "ok" : 0, 
              "errmsg" : "BufBuilder attempted to grow() to 838295666 bytes, past the 64MB limit.", 
              "code" : 13548, 
              "codeName" : "Location13548" 
      } : aggregate failed : 
      _getErrorWithCode@src/mongo/shell/utils.js:25:13 
      doassert@src/mongo/shell/assert.js:18:14 
      _assertCommandWorked@src/mongo/shell/assert.js:536:17 
      assert.commandWorked@src/mongo/shell/assert.js:620:16 
      DB.prototype._runAggregate@src/mongo/shell/db.js:260:9 
      DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12

      Or in this segfault:

       

      2019-02-06T10:26:07.853+0000 F - [conn4] Invalid access at address: 0x5593140fad97
      2019-02-06T10:26:07.892+0000 F - [conn4] Got signal: 11 (Segmentation fault).
      0x558c0d646b61 0x558c0d645d79 0x558c0d6463e6 0x7fbb5bf33390 0x558c0d46ae7f 0x558c0c56b8f6 0x558c0c56d1d0 0x558c0c570282 0x558c0c5710d4 0x558c0c5715bb 0x558c0cc1e96c 0x558c0cc203cc 0x558c0cc20c67 0x558c0cc56858 0x558c0cc6d56d 0x558c0c5311b5 0x558c0c53136c 0x558c0c5318bb 0x558c0c58229d 0x558c0c582c2b 0x558c0c32937d 0x558c0c31f2a4 0x558c0d0b13b9 0x558c0bd10cb5 0x558c0bd129a9 0x558c0bd138e1 0x558c0bcff15a 0x558c0bd0bc0a 0x558c0bd06897 0x558c0bd0a0e1 0x558c0cea17c2 0x558c0bd04a80 0x558c0bd07c65 0x558c0bd05fd7 0x558c0bd0691d 0x558c0bd0a0e1 0x558c0cea1d25 0x558c0d59f6e4 0x7fbb5bf296ba 0x7fbb5bc5f41d
      ----- BEGIN BACKTRACE -----
      {"backtrace":[{"b":"558C0B24A000","o":"23FCB61","s":"_ZN5mongo15printStackTraceERSo"},{"b":"558C0B24A000","o":"23FBD79"},{"b":"558C0B24A000","o":"23FC3E6"},{"b":"7FBB5BF22000","o":"11390"},{"b":"558C0B24A000","o":"2220E7F","s":"_ZNK5mongo13CollationSpec6toBSONEv"},{"b":"558C0B24A000","o":"13218F6"},{"b":"558C0B24A000","o":"13231D0","s":"_ZN5mongo9PipelineD15prepareExecutorEPNS_16OperationContextEPNS_10CollectionERKNS_15NamespaceStringEPNS_8PipelineERKN5boost13intrusive_ptrINS_17ExpressionContextEEEbRKNSB_INS_18DocumentSourceSortEEERKNS_11DepsTrackerERKNS_7BSONObjEPKNS_18AggregationRequestEPSN_ST_"},{"b":"558C0B24A000","o":"1326282","s":"_ZN5mongo9PipelineD19prepareCursorSourceEPNS_10CollectionERKNS_15NamespaceStringEPKNS_18AggregationRequestEPNS_8PipelineE"},{"b":"558C0B24A000","o":"13270D4","s":"_ZN5mongo9PipelineD15MongoDInterface28attachCursorSourceToPipelineERKN5boost13intrusive_ptrINS_17ExpressionContextEEEPNS_8PipelineE"},{"b":"558C0B24A000","o":"13275BB","s":"_ZN5mongo9PipelineD15MongoDInterface12makePipelineERKSt6vectorINS_7BSONObjESaIS3_EERKN5boost13intrusive_ptrINS_17ExpressionContextEEENS_21MongoProcessInterface19MakePipelineOptionsE"},{"b":"558C0B24A000","o":"19D496C","s":"_ZN5mongo20DocumentSourceLookUp13buildPipelineERKNS_8DocumentE"},{"b":"558C0B24A000","o":"19D63CC","s":"_ZN5mongo20DocumentSourceLookUp12unwindResultEv"},{"b":"558C0B24A000","o":"19D6C67","s":"_ZN5mongo20DocumentSourceLookUp7getNextEv"},{"b":"558C0B24A000","o":"1A0C858","s":"_ZN5mongo42DocumentSourceSingleDocumentTransformation7getNextEv"},{"b":"558C0B24A000","o":"1A2356D","s":"_ZN5mongo8Pipeline7getNextEv"},{"b":"558C0B24A000","o":"12E71B5","s":"_ZN5mongo18PipelineProxyStage11getNextBsonEv"},{"b":"558C0B24A000","o":"12E736C","s":"_ZN5mongo18PipelineProxyStage6doWorkEPm"},{"b":"558C0B24A000","o":"12E78BB","s":"_ZN5mongo9PlanStage4workEPm"},{"b":"558C0B24A000","o":"133829D","s":"_ZN5mongo12PlanExecutor11getNextImplEPNS_11SnapshottedINS_7BSONObjEEEPNS_8RecordIdE"},{"b":"558C0B24A000","o":"1338C2B","s":"_ZN5mongo12PlanExecutor7getNextEPNS_7BSONObjEPNS_8RecordIdE"},{"b":"558C0B24A000","o":"10DF37D","s":"_ZN5mongo12runAggregateEPNS_16OperationContextERKNS_15NamespaceStringERKNS_18AggregationRequestERKNS_7BSONObjERNS_14BSONObjBuilderE"},{"b":"558C0B24A000","o":"10D52A4"},{"b":"558C0B24A000","o":"1E673B9","s":"_ZN5mongo12BasicCommand10Invocation3runEPNS_16OperationContextEPNS_19CommandReplyBuilderE"},{"b":"558C0B24A000","o":"AC6CB5"},{"b":"558C0B24A000","o":"AC89A9"},{"b":"558C0B24A000","o":"AC98E1","s":"_ZN5mongo23ServiceEntryPointCommon13handleRequestEPNS_16OperationContextERKNS_7MessageERKNS0_5HooksE"},{"b":"558C0B24A000","o":"AB515A","s":"_ZN5mongo23ServiceEntryPointMongod13handleRequestEPNS_16OperationContextERKNS_7MessageE"},{"b":"558C0B24A000","o":"AC1C0A","s":"_ZN5mongo19ServiceStateMachine15_processMessageENS0_11ThreadGuardE"},{"b":"558C0B24A000","o":"ABC897","s":"_ZN5mongo19ServiceStateMachine15_runNextInGuardENS0_11ThreadGuardE"},{"b":"558C0B24A000","o":"AC00E1"},{"b":"558C0B24A000","o":"1C577C2","s":"_ZN5mongo9transport26ServiceExecutorSynchronous8scheduleESt8functionIFvvEENS0_15ServiceExecutor13ScheduleFlagsENS0_23ServiceExecutorTaskNameE"},{"b":"558C0B24A000","o":"ABAA80","s":"_ZN5mongo19ServiceStateMachine22_scheduleNextWithGuardENS0_11ThreadGuardENS_9transport15ServiceExecutor13ScheduleFlagsENS2_23ServiceExecutorTaskNameENS0_9OwnershipE"},{"b":"558C0B24A000","o":"ABDC65","s":"_ZN5mongo19ServiceStateMachine15_sourceCallbackENS_6StatusE"},{"b":"558C0B24A000","o":"ABBFD7","s":"_ZN5mongo19ServiceStateMachine14_sourceMessageENS0_11ThreadGuardE"},{"b":"558C0B24A000","o":"ABC91D","s":"_ZN5mongo19ServiceStateMachine15_runNextInGuardENS0_11ThreadGuardE"},{"b":"558C0B24A000","o":"AC00E1"},{"b":"558C0B24A000","o":"1C57D25"},{"b":"558C0B24A000","o":"23556E4"},{"b":"7FBB5BF22000","o":"76BA"},{"b":"7FBB5BB58000","o":"10741D","s":"clone"}],"processInfo":{ "mongodbVersion" : "4.0.6", "gitVersion" : "caa42a1f75a56c7643d0b68d3880444375ec42e3", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.15.0-1031-aws", "version" : "#33-Ubuntu SMP Fri Dec 7 09:32:27 UTC 2018", "machine" : "x86_64" }, "somap" : [ { "b" : "558C0B24A000", "elfType" : 3, "buildId" : "FAEABC5A7AEF9457109EED554DE5AD1A4812715B" }, { "b" : "7FFED356D000", "elfType" : 3, "buildId" : "E0D82228A0ED2569F98F7426BBBBF98D406722D4" }, { "b" : "7FBB5D333000", "path" : "/usr/lib/x86_64-linux-gnu/libcurl.so.4", "elfType" : 3, "buildId" : "E2D1DB1857AE8F07908959381751796E89FF56BB" }, { "b" : "7FBB5D118000", "path" : "/lib/x86_64-linux-gnu/libresolv.so.2", "elfType" : 3, "buildId" : "6EF73266978476EF9F2FD2CF31E57F4597CB74F8" }, { "b" : "7FBB5CCD3000", "path" : "/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "8942CA58A3B910E883CC31E04A23DBD09729B4B0" }, { "b" : "7FBB5CA6A000", "path" : "/lib/x86_64-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "473092A9AF373FB0CAB555F9A003BC67F47756B6" }, { "b" : "7FBB5C866000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "8CC8D0D119B142D839800BFF71FB71E73AEA7BD4" }, { "b" : "7FBB5C65E000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "89C34D7A182387D76D5CDA1F7718F5D58824DFB3" }, { "b" : "7FBB5C355000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "DFB85DE42DAFFD09640C8FE377D572DE3E168920" }, { "b" : "7FBB5C13F000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "68220AE2C65D65C1B6AAA12FA6765A6EC2F5F434" }, { "b" : "7FBB5BF22000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "CE17E023542265FC11D9BC8F534BB4F070493D30" }, { "b" : "7FBB5BB58000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "B5381A457906D279073822A5CEB24C4BFEF94DDB" }, { "b" : "7FBB5D5A2000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "5D7B6259552275A3C17BD4C3FD05F5A6BF40CAA5" }, { "b" : "7FBB5B925000", "path" : "/usr/lib/x86_64-linux-gnu/libidn.so.11", "elfType" : 3, "buildId" : "E09D3783AD1D0BBCD3204FA01E4EF6D756E18F57" }, { "b" : "7FBB5B709000", "path" : "/usr/lib/x86_64-linux-gnu/librtmp.so.1", "elfType" : 3, "buildId" : "8D1CC1204D6B6D33BD1D2C5A2A0516A2234322CF" }, { "b" : "7FBB5B4BF000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2", "elfType" : 3, "buildId" : "41971A4A3CCDC54A447F41DF4BD96C948C546E0E" }, { "b" : "7FBB5B2B0000", "path" : "/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2", "elfType" : 3, "buildId" : "5B146086EC173C299BA45F0C92E068D68CC7AD37" }, { "b" : "7FBB5B05F000", "path" : "/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2", "elfType" : 3, "buildId" : "D02A94DB90567C2C45F40C8565809A041FD22A55" }, { "b" : "7FBB5AE45000", "path" : "/lib/x86_64-linux-gnu/libz.so.1", "elfType" : 3, "buildId" : "8D9BD4CE26E45EF16075C67D5F5EEAFD8B562832" }, { "b" : "7FBB5AB15000", "path" : "/usr/lib/x86_64-linux-gnu/libgnutls.so.30", "elfType" : 3, "buildId" : "3CE893F6D1382C2C7648DCCB06E71B1C7E0861CC" }, { "b" : "7FBB5A8E2000", "path" : "/usr/lib/x86_64-linux-gnu/libhogweed.so.4", "elfType" : 3, "buildId" : "B11678F560199547DCF726384EA39153EE0DFABF" }, { "b" : "7FBB5A6AC000", "path" : "/usr/lib/x86_64-linux-gnu/libnettle.so.6", "elfType" : 3, "buildId" : "D6B36C5A463EE0FA84FDD6D5FD3F7726EDB90D54" }, { "b" : "7FBB5A42C000", "path" : "/usr/lib/x86_64-linux-gnu/libgmp.so.10", "elfType" : 3, "buildId" : "7B3533D5998D20EE1A1BE3F87789B69041E7F620" }, { "b" : "7FBB5A15A000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.3", "elfType" : 3, "buildId" : "0EEF7058B0737B68BDF89E5DC604D0AC389C8BB1" }, { "b" : "7FBB59F2B000", "path" : "/usr/lib/x86_64-linux-gnu/libk5crypto.so.3", "elfType" : 3, "buildId" : "FFBA483A43D9EF73925AC116811890C037523DA1" }, { "b" : "7FBB59D27000", "path" : "/lib/x86_64-linux-gnu/libcom_err.so.2", "elfType" : 3, "buildId" : "1E16CB57F699E215A2A8D4EFEF90883BC749B12D" }, { "b" : "7FBB59B1C000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5support.so.0", "elfType" : 3, "buildId" : "B789D8D4B4FC333405AB34387D9237F954060EA4" }, { "b" : "7FBB59901000", "path" : "/usr/lib/x86_64-linux-gnu/libsasl2.so.2", "elfType" : 3, "buildId" : "87783DF8A1058CD150F8886CB36340384093C18F" }, { "b" : "7FBB596C0000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi.so.3", "elfType" : 3, "buildId" : "1FE877BE52A424D0636AFD4D35BB330E41D6E0F3" }, { "b" : "7FBB5945C000", "path" : "/usr/lib/x86_64-linux-gnu/libp11-kit.so.0", "elfType" : 3, "buildId" : "A0E2D03FF5CF65937F4425D4EFD4D655243809EB" }, { "b" : "7FBB59249000", "path" : "/usr/lib/x86_64-linux-gnu/libtasn1.so.6", "elfType" : 3, "buildId" : "E07E186694852D8F69459C6AB28A53F8DA3CE3B6" }, { "b" : "7FBB59045000", "path" : "/lib/x86_64-linux-gnu/libkeyutils.so.1", "elfType" : 3, "buildId" : "3364D4BF2113C4E8D17EF533867ECC99A53413D6" }, { "b" : "7FBB58E3C000", "path" : "/usr/lib/x86_64-linux-gnu/libheimntlm.so.0", "elfType" : 3, "buildId" : "73A8EADBC85860662B24850E71D4AFBE22C33359" }, { "b" : "7FBB58BB2000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.26", "elfType" : 3, "buildId" : "59E742306A4EA2872E061ECCE92F35FADDA75357" }, { "b" : "7FBB58910000", "path" : "/usr/lib/x86_64-linux-gnu/libasn1.so.8", "elfType" : 3, "buildId" : "E5C159E415406AE79D21056D752BA949C408B5B1" }, { "b" : "7FBB586DD000", "path" : "/usr/lib/x86_64-linux-gnu/libhcrypto.so.4", "elfType" : 3, "buildId" : "7D15576E1F096614D360784E4A01A1F5FAF908C9" }, { "b" : "7FBB584C7000", "path" : "/usr/lib/x86_64-linux-gnu/libroken.so.18", "elfType" : 3, "buildId" : "481DB33C28D88E43DA6BED65E1A7599407D4D818" }, { "b" : "7FBB582BF000", "path" : "/usr/lib/x86_64-linux-gnu/libffi.so.6", "elfType" : 3, "buildId" : "9D9C958F1F4894AFEF6AECD90D1C430EA29AC34F" }, { "b" : "7FBB58096000", "path" : "/usr/lib/x86_64-linux-gnu/libwind.so.0", "elfType" : 3, "buildId" : "57E25072866B2D30CF02EBE7AE623B84F96FA700" }, { "b" : "7FBB57E87000", "path" : "/usr/lib/x86_64-linux-gnu/libheimbase.so.1", "elfType" : 3, "buildId" : "F6F1B4E9F89B716C4A0BA5819BDFFAF4A13EFB91" }, { "b" : "7FBB57C3C000", "path" : "/usr/lib/x86_64-linux-gnu/libhx509.so.5", "elfType" : 3, "buildId" : "C60082E3BB78D0D42868D9B359B89BF66CE5A1A7" }, { "b" : "7FBB57967000", "path" : "/usr/lib/x86_64-linux-gnu/libsqlite3.so.0", "elfType" : 3, "buildId" : "D9782BA023CAEC26B15D8676E3A5D07B55E121EF" }, { "b" : "7FBB5772F000", "path" : "/lib/x86_64-linux-gnu/libcrypt.so.1", "elfType" : 3, "buildId" : "7BDD51353D50310FFA1587E4AA01B40ABE32D582" } ] }}
      mongod(_ZN5mongo15printStackTraceERSo+0x41) [0x558c0d646b61]
      mongod(+0x23FBD79) [0x558c0d645d79]
      mongod(+0x23FC3E6) [0x558c0d6463e6]
      libpthread.so.0(+0x11390) [0x7fbb5bf33390]
      mongod(_ZNK5mongo13CollationSpec6toBSONEv+0x2BF) [0x558c0d46ae7f]
      mongod(+0x13218F6) [0x558c0c56b8f6]
      mongod(_ZN5mongo9PipelineD15prepareExecutorEPNS_16OperationContextEPNS_10CollectionERKNS_15NamespaceStringEPNS_8PipelineERKN5boost13intrusive_ptrINS_17ExpressionContextEEEbRKNSB_INS_18DocumentSourceSortEEERKNS_11DepsTrackerERKNS_7BSONObjEPKNS_18AggregationRequestEPSN_ST_+0x590) [0x558c0c56d1d0]
      mongod(_ZN5mongo9PipelineD19prepareCursorSourceEPNS_10CollectionERKNS_15NamespaceStringEPKNS_18AggregationRequestEPNS_8PipelineE+0x732) [0x558c0c570282]
      mongod(_ZN5mongo9PipelineD15MongoDInterface28attachCursorSourceToPipelineERKN5boost13intrusive_ptrINS_17ExpressionContextEEEPNS_8PipelineE+0x254) [0x558c0c5710d4]
      mongod(_ZN5mongo9PipelineD15MongoDInterface12makePipelineERKSt6vectorINS_7BSONObjESaIS3_EERKN5boost13intrusive_ptrINS_17ExpressionContextEEENS_21MongoProcessInterface19MakePipelineOptionsE+0xEB) [0x558c0c5715bb]
      mongod(_ZN5mongo20DocumentSourceLookUp13buildPipelineERKNS_8DocumentE+0x1EC) [0x558c0cc1e96c]
      mongod(_ZN5mongo20DocumentSourceLookUp12unwindResultEv+0xFC) [0x558c0cc203cc]
      mongod(_ZN5mongo20DocumentSourceLookUp7getNextEv+0x47) [0x558c0cc20c67]
      mongod(_ZN5mongo42DocumentSourceSingleDocumentTransformation7getNextEv+0x38) [0x558c0cc56858]
      mongod(_ZN5mongo8Pipeline7getNextEv+0x3D) [0x558c0cc6d56d]
      mongod(_ZN5mongo18PipelineProxyStage11getNextBsonEv+0x35) [0x558c0c5311b5]
      mongod(_ZN5mongo18PipelineProxyStage6doWorkEPm+0xFC) [0x558c0c53136c]
      mongod(_ZN5mongo9PlanStage4workEPm+0x6B) [0x558c0c5318bb]
      mongod(_ZN5mongo12PlanExecutor11getNextImplEPNS_11SnapshottedINS_7BSONObjEEEPNS_8RecordIdE+0x50D) [0x558c0c58229d]
      mongod(_ZN5mongo12PlanExecutor7getNextEPNS_7BSONObjEPNS_8RecordIdE+0x4B) [0x558c0c582c2b]
      mongod(_ZN5mongo12runAggregateEPNS_16OperationContextERKNS_15NamespaceStringERKNS_18AggregationRequestERKNS_7BSONObjERNS_14BSONObjBuilderE+0x1E5D) [0x558c0c32937d]
      mongod(+0x10D52A4) [0x558c0c31f2a4]
      mongod(_ZN5mongo12BasicCommand10Invocation3runEPNS_16OperationContextEPNS_19CommandReplyBuilderE+0xD9) [0x558c0d0b13b9]
      mongod(+0xAC6CB5) [0x558c0bd10cb5]
      mongod(+0xAC89A9) [0x558c0bd129a9]
      mongod(_ZN5mongo23ServiceEntryPointCommon13handleRequestEPNS_16OperationContextERKNS_7MessageERKNS0_5HooksE+0x3C1) [0x558c0bd138e1]
      mongod(_ZN5mongo23ServiceEntryPointMongod13handleRequestEPNS_16OperationContextERKNS_7MessageE+0x3A) [0x558c0bcff15a]
      mongod(_ZN5mongo19ServiceStateMachine15_processMessageENS0_11ThreadGuardE+0xBA) [0x558c0bd0bc0a]
      mongod(_ZN5mongo19ServiceStateMachine15_runNextInGuardENS0_11ThreadGuardE+0x97) [0x558c0bd06897]
      mongod(+0xAC00E1) [0x558c0bd0a0e1]
      mongod(_ZN5mongo9transport26ServiceExecutorSynchronous8scheduleESt8functionIFvvEENS0_15ServiceExecutor13ScheduleFlagsENS0_23ServiceExecutorTaskNameE+0x1A2) [0x558c0cea17c2]
      mongod(_ZN5mongo19ServiceStateMachine22_scheduleNextWithGuardENS0_11ThreadGuardENS_9transport15ServiceExecutor13ScheduleFlagsENS2_23ServiceExecutorTaskNameENS0_9OwnershipE+0x150) [0x558c0bd04a80]
      mongod(_ZN5mongo19ServiceStateMachine15_sourceCallbackENS_6StatusE+0xB05) [0x558c0bd07c65]
      mongod(_ZN5mongo19ServiceStateMachine14_sourceMessageENS0_11ThreadGuardE+0x357) [0x558c0bd05fd7]
      mongod(_ZN5mongo19ServiceStateMachine15_runNextInGuardENS0_11ThreadGuardE+0x11D) [0x558c0bd0691d]
      mongod(+0xAC00E1) [0x558c0bd0a0e1]
      mongod(+0x1C57D25) [0x558c0cea1d25]
      mongod(+0x23556E4) [0x558c0d59f6e4]
      libpthread.so.0(+0x76BA) [0x7fbb5bf296ba]
      libc.so.6(clone+0x6D) [0x7fbb5bc5f41d]
      ----- END BACKTRACE -----

       

      The issue appears to be caused by this expression in $lookup.pipeline:

       

      {
        '$match': {
          '$expr': {
            '$eq': ['$campaign_id', '$$action_campaign_id'],
          },
        },
      }

       

      Removing it makes the output appear:

       

      { "_id" : ObjectId("5c59974b6c62000010a956ff"), "brands" : [ "Test" ], "campaign" : { "_id" : ObjectId("5c59974b6c62000010a956ff")
      , "name" : "FR_WK2_test2", "company_id" : 1, "created_at" : ISODate("2019-02-05T14:01:47.268Z") }, "kp
      i" : [ ] } 
      { "_id" : ObjectId("5c5994639df716001e51e2c4"), "brands" : [ "Test" ], "campaign" : { "_id" : ObjectId("5c5994639df716001e51e2c4")
      , "name" : "FR_WK1_test", "company_id" : 1, "created_at" : ISODate("2019-02-05T13:49:23.665Z") }, "kpi
      " : [ ] }

       

      As you can probably tell, the $match expression doesn't change anything here, since the data collection is empty. However, it was added before to address performance when data collection exists and contains big amount of documents and I would like to leave it, especially given the fact that it looks totally okay given the documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#specify-multiple-join-conditions-with-lookup

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            hbielenia Hubert Bielenia
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: