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

Update with aggregation pipeline shows in oplog as replace operation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 4.2.0-rc2
    • None
    • None
    • None
    • Query Execution
    • Fully Compatible

    Description

      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 ?

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            wan.bachtiar@mongodb.com Wan Bachtiar
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: