Change Stream breaks on document with top-level $v

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: 8.0.13
    • Component/s: Change streams
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • v8.2, v8.0, v7.0, v6.0
    • Hide

      1. Open a change stream. (global, db, or collection)
      2. Insert a document.
      3. Replace that document with a version of itself with $v: 2 as a top-level field.
      4. Iterate the change stream. You’ll eventually see the getMore error.

      Show
      1. Open a change stream. (global, db, or collection) 2. Insert a document. 3. Replace that document with a version of itself with $v: 2 as a top-level field. 4. Iterate the change stream. You’ll eventually see the getMore error.
    • QE 2025-09-29, QE 2025-10-13
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      > db.foo.insert({_id: 2})
      
      > db.runCommand({update: "foo", updates: [{q: {_id: 2}, u: [{$replaceWith: {$literal: {_id:2, $v: 2}}}]}]})
      

      … does this in the (global) change stream:

      {
        _id: {
          _data: '8268D33CF7000000012B042C0100296E5A10043BA8D84899464C078E0C29EE953D547C463C6F7065726174696F6E54797065003C696E736572740046646F63756D656E744B657900461E5F6964002B04000004'
        },
        operationType: 'insert',
        clusterTime: Timestamp({ t: 1758674167, i: 1 }),
        wallTime: ISODate('2025-09-24T00:36:07.146Z'),
        fullDocument: { _id: 2 },
        ns: { db: 'test', coll: 'foo' },
        documentKey: { _id: 2 }
      }
      MongoServerError[Location40532]: Executor error during getMore :: caused by :: Entry field "o.diff" should be object, found: missing
      

      The server should simply show the `replace` event.

            Assignee:
            Jan Steemann
            Reporter:
            Felipe Gasper
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: