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

source namespace is not reported correctly if $out is used

    • Fully Compatible
    • ALL
    • v4.2
    • Query 2019-07-01

      If the aggregation is using the $out stage, the logged command will indicate an incorrect source namespace. The outcome is different depending on the version of the server being used:

      "v4.2.0-rc0, $out not used"
      // Note that the namespace is set to the source NS, as expected
      
      2019-06-14T05:49:15.436+0000 I  COMMAND  [conn1] command test.jobOrdersSV appName: "MongoDB Shell" command: aggregate { aggregate: "jobOrdersSV", pipeline: [ { $match: { modifyDateStringSV: new Date(3811610871405) } }, { $group: { _id: "$dateStringSV" } } ], cursor: {}, lsid: { id: UUID("f4b366a6-c569-4270-8066-d4ec26c16818") }, $db: "test" } planSummary: COLLSCAN keysExamined:0 docsExamined:1 cursorExhausted:1 numYields:0 nreturned:1 queryHash:6918F44F planCacheKey:6918F44F reslen:129 locks:{ ReplicationStateTransition: { acquireCount: { w: 2 } }, Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 2 } }, Collection: { acquireCount: { r: 2 } }, Mutex: { acquireCount: { r: 2 } } } storage:{} protocol:op_msg 0ms
      
      "v4.2.0-rc0, $out is present"
      // Note that the namespace is now set to _tempNS
      
      2019-06-14T05:51:46.134+0000 I  COMMAND  [conn1] command test.tmp.agg_out.4 appName: "MongoDB Shell" command: aggregate { aggregate: "jobOrdersSV", pipeline: [ { $match: { modifyDateStringSV: new Date(3811610871405) } }, { $group: { _id: "$dateStringSV" } }, { $out: "dateBenchmark" } ], cursor: {}, lsid: { id: UUID("f4b366a6-c569-4270-8066-d4ec26c16818") }, $db: "test" } planSummary: COLLSCAN keysExamined:0 docsExamined:1 ninserted:1 cursorExhausted:1 keysInserted:1 numYields:1 nreturned:0 queryHash:6918F44F planCacheKey:6918F44F reslen:105 locks:{ ParallelBatchWriter: { acquireCount: { r: 15 } }, ReplicationStateTransition: { acquireCount: { w: 22 } }, Global: { acquireCount: { r: 16, w: 6 } }, Database: { acquireCount: { r: 9, w: 5, W: 1 } }, Collection: { acquireCount: { r: 11, w: 2, W: 3 } }, Mutex: { acquireCount: { r: 13 } } } flowControl:{ acquireCount: 5 } storage:{} protocol:op_msg 17ms
      
      "v3.6.9, $out not used"
      // Note that the namespace is set to the source NS, as expected
      
      2019-06-14T13:39:35.525+1000 I COMMAND  [conn60430] command test.jobOrdersSV 
      appName: "MongoDB Shell" command: aggregate { 
          aggregate: "jobOrdersSV", pipeline: [ 
          { $match: { modifyDateStringSV: new Date(3811610871405) } }, 
          { $group: { _id: "$dateStringSV" } } ], 
          cursor: {}, lsid: { id: UUID("0612e78e-2d31-4df2-9b94-a8fa33907ad1") }, $clusterTime: { clusterTime: Timestamp(1560483562, 1), signature: { hash: BinData(0, 151208BE042C0F758C020E51B11E627BC9EFCEBE), keyId: 6691479512963612673 } }, $db: "test" } planSummary: COLLSCAN keysExamined:0 docsExamined:100000 cursorExhausted:1 numYields:781 nreturned:1 reslen:238 locks:{ Global: { acquireCount: { r: 1566 } }, Database: { acquireCount: { r: 783 } }, Collection: { acquireCount: { r: 783 } } } 
      protocol:op_msg 83ms
      
      "v3.6.9, $out is present"
      // The namespace is now set to the outputNs value
      
      2019-06-14T13:37:23.761+1000 I COMMAND  [conn60430] command test.dateBenchmark 
      appName: "MongoDB Shell" command: aggregate { 
          aggregate: "jobOrdersSV", pipeline: [ 
          { $match: { modifyDateStringSV: new Date(3811610871405) } }, 
          { $group: { _id: "$dateStringSV" } }, 
          { $out: "dateBenchmark" } ], 
          cursor: {}, lsid: { id: UUID("0612e78e-2d31-4df2-9b94-a8fa33907ad1") }, $clusterTime: { clusterTime: Timestamp(1560483433, 1), signature: { hash: BinData(0, 037953E09BF11E83C7C264C1EDDE9916DDFE5E87), keyId: 6691479512963612673 } }, $db: "test" } planSummary: COLLSCAN keysExamined:0 docsExamined:100000 cursorExhausted:1 numYields:782 nreturned:0 reslen:214 locks:{ Global: { acquireCount: { r: 1589, w: 8, W: 1 }, acquireWaitCount: { W: 1 }, timeAcquiringMicros: { W: 3 } }, Database: { acquireCount: { r: 788, w: 6, R: 2, W: 2 } }, Collection: { acquireCount: { r: 787, w: 2 } }, oplog: { acquireCount: { w: 3 } } } 
      protocol:op_msg 254ms
      

      The v4.0.9 shows the same results as 3.6.9.

      The issue manifests with "$out" but not with "$merge".

            Assignee:
            anton.korshunov@mongodb.com Anton Korshunov
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: