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

Update with aggregation pipeline shows in oplog as replace operation

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.0-rc2
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Fully Compatible

      Normal update operation in shows up in oplog (changestream) as operationType update, while update with aggregation pipeline shows up in oplog (changestream) as operationType replace.

      Example:

      db.test.update({a:1}, {$set:{b:"foo"}})
      

      Output:

      {   '_id': {   '_data': '...'},
          'clusterTime': Timestamp(1562633420, 1),
          'documentKey': {'_id': ObjectId('5d1ede84705cbd6a35d69fcf')},
          'ns': {'coll': 'test', 'db': 'test'},
          'operationType': 'update',
          'updateDescription': {'removedFields': [], 'updatedFields': {'b': 'foo'}}}
      

      While update with aggregation:

      db.test.update({a:1}, [{$set:{b:"bar"}}])
      

      Output:

      {   '_id': {   '_data': '...'},
          'clusterTime': Timestamp(1562633424, 1),
          'documentKey': {'_id': ObjectId('5d1ede84705cbd6a35d69fcf')},
          'fullDocument': {   '_id': ObjectId('5d1ede84705cbd6a35d69fcf'),
                              'a': 1.0,
                              'b': 'bar'},
          'ns': {'coll': 'test', 'db': 'test'},
          'operationType': 'replace'}
      

      Would this behaviour likely to be changed in the future ?

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: