[SERVER-41756] source namespace is not reported correctly if $out is used Created: 14/Jun/19  Updated: 29/Oct/23  Resolved: 27/Jun/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 4.2.0-rc3, 4.3.1

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Anton Korshunov
Resolution: Fixed Votes: 1
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Sprint: Query 2019-07-01
Participants:
Case:

 Description   

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".



 Comments   
Comment by Githook User [ 27/Jun/19 ]

Author:

{'name': 'Anton Korshunov', 'email': 'anton.korshunov@mongodb.com', 'username': 'antkorsh'}

Message: SERVER-41756 source namespace is not reported correctly if $out is used

(cherry picked from commit 40f401824c4fb8925f063239d7855fe742e33d55)
Branch: v4.2
https://github.com/mongodb/mongo/commit/45653e3fae7492fd2c0e13d25aab0269b7280b79

Comment by Githook User [ 27/Jun/19 ]

Author:

{'name': 'Anton Korshunov', 'email': 'anton.korshunov@mongodb.com', 'username': 'antkorsh'}

Message: SERVER-41756 source namespace is not reported correctly if $out is used
Branch: master
https://github.com/mongodb/mongo/commit/40f401824c4fb8925f063239d7855fe742e33d55

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